Files
chargeflow/components/loadbalancer/include/loadbalancer_events.h

70 lines
1.2 KiB
C

// components/loadbalancer/include/loadbalancer_events.h
#pragma once
#include "esp_event.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
ESP_EVENT_DECLARE_BASE(LOADBALANCER_EVENTS);
typedef enum
{
LOADBALANCER_EVENT_INIT = 0,
LOADBALANCER_EVENT_STATE_CHANGED,
/*
* 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;
} loadbalancer_state_event_t;
/*
* MASTER: no slave_id.
*/
typedef struct
{
uint16_t max_current;
int64_t timestamp_us;
} loadbalancer_master_limit_event_t;
/*
* SLAVE: includes slave_id.
*/
typedef struct
{
uint8_t slave_id;
uint16_t max_current;
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;
} loadbalancer_slave_status_event_t;
#ifdef __cplusplus
}
#endif