chore: snapshot before shared RS485 bus integration

This commit is contained in:
2026-07-22 15:36:04 +01:00
parent ef02e5c5f5
commit 2a803fcef1
167 changed files with 5749 additions and 1128 deletions

0
components/loadbalancer/include/grid_limiter.h Executable file → Normal file
View File

0
components/loadbalancer/include/input_filter.h Executable file → Normal file
View File

21
components/loadbalancer/include/loadbalancer.h Executable file → Normal file
View File

@@ -9,11 +9,32 @@ extern "C" {
#include <stdint.h>
#include "esp_err.h"
/**
* @brief Operational current limiting mode.
*
* This is owned by the loadbalancer/policy layer. MQTT/REST should only
* request a mode change; they should not persist or re-apply their own mode.
*/
typedef enum
{
LOADBALANCER_LIMIT_MODE_OFF = 0,
LOADBALANCER_LIMIT_MODE_MANUAL,
LOADBALANCER_LIMIT_MODE_GRID,
LOADBALANCER_LIMIT_MODE_SOLAR,
LOADBALANCER_LIMIT_MODE_GRID_SOLAR
} loadbalancer_limit_mode_t;
void loadbalancer_init(void);
void loadbalancer_set_enabled(bool enabled);
bool loadbalancer_is_enabled(void);
// Operational limit mode
esp_err_t loadbalancer_set_limit_mode(loadbalancer_limit_mode_t mode);
loadbalancer_limit_mode_t loadbalancer_get_limit_mode(void);
const char *loadbalancer_limit_mode_to_str(loadbalancer_limit_mode_t mode);
bool loadbalancer_limit_mode_from_str(const char *str, loadbalancer_limit_mode_t *out);
// GRID limit (A)
void loadbalancer_grid_set_enabled(bool en);
bool loadbalancer_grid_is_enabled(void);

View File

@@ -2,9 +2,9 @@
#pragma once
#include "esp_event.h"
#include <stdint.h>
#include <stdbool.h>
#include "esp_timer.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -12,49 +12,59 @@ extern "C" {
ESP_EVENT_DECLARE_BASE(LOADBALANCER_EVENTS);
typedef enum {
typedef enum
{
LOADBALANCER_EVENT_INIT = 0,
LOADBALANCER_EVENT_STATE_CHANGED,
LOADBALANCER_EVENT_GLOBAL_CURRENT_LIMIT,
// IMPORTANT: eventos separados e payloads diferentes
/*
* Current limit events.
*
* MASTER and SLAVE use different payloads intentionally.
*/
LOADBALANCER_EVENT_MASTER_CURRENT_LIMIT,
LOADBALANCER_EVENT_SLAVE_CURRENT_LIMIT,
/*
* Status received from slave connectors.
*/
LOADBALANCER_EVENT_SLAVE_STATUS
} loadbalancer_event_id_t;
typedef struct {
bool enabled;
int64_t timestamp_us;
typedef struct
{
bool enabled;
int64_t timestamp_us;
} loadbalancer_state_event_t;
typedef struct {
float limit;
int64_t timestamp_us;
} loadbalancer_global_limit_event_t;
// MASTER: NÃO tem slave_id
typedef struct {
/*
* MASTER: no slave_id.
*/
typedef struct
{
uint16_t max_current;
int64_t timestamp_us;
int64_t timestamp_us;
} loadbalancer_master_limit_event_t;
// SLAVE: tem slave_id
typedef struct {
uint8_t slave_id;
/*
* SLAVE: includes slave_id.
*/
typedef struct
{
uint8_t slave_id;
uint16_t max_current;
int64_t timestamp_us;
int64_t timestamp_us;
} loadbalancer_slave_limit_event_t;
typedef struct {
uint8_t slave_id;
bool charging;
float hw_max_current;
float runtime_current;
int64_t timestamp_us;
typedef struct
{
uint8_t slave_id;
bool charging;
float hw_max_current;
float runtime_current;
int64_t timestamp_us;
} loadbalancer_slave_status_event_t;
#ifdef __cplusplus
}
#endif
#endif

0
components/loadbalancer/include/pv_optimizer.h Executable file → Normal file
View File