78 lines
2.0 KiB
C
Executable File
78 lines
2.0 KiB
C
Executable File
#ifndef EVSE_EVENTS_H
|
|
#define EVSE_EVENTS_H
|
|
|
|
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include "esp_event.h"
|
|
|
|
ESP_EVENT_DECLARE_BASE(EVSE_EVENTS);
|
|
|
|
typedef enum {
|
|
EVSE_EVENT_INIT,
|
|
EVSE_EVENT_STATE_CHANGED,
|
|
EVSE_EVENT_CONFIG_UPDATED,
|
|
EVSE_EVENT_ENABLE_UPDATED,
|
|
EVSE_EVENT_AVAILABLE_UPDATED,
|
|
EVSE_EVENT_SESSION,
|
|
} evse_event_id_t;
|
|
|
|
// -----------------
|
|
// Eventos de STATE
|
|
// -----------------
|
|
typedef enum {
|
|
EVSE_STATE_EVENT_IDLE,
|
|
EVSE_STATE_EVENT_WAITING,
|
|
EVSE_STATE_EVENT_CHARGING,
|
|
EVSE_STATE_EVENT_FAULT
|
|
} evse_state_event_t;
|
|
|
|
typedef struct {
|
|
evse_state_event_t state;
|
|
} evse_state_event_data_t;
|
|
|
|
// -----------------
|
|
// Eventos de SESSÃO
|
|
// -----------------
|
|
typedef enum {
|
|
EVSE_SESSION_EVENT_STARTED = 0,
|
|
EVSE_SESSION_EVENT_FINISHED,
|
|
} evse_session_event_type_t;
|
|
|
|
typedef struct {
|
|
evse_session_event_type_t type; ///< STARTED / FINISHED
|
|
|
|
// campos básicos da sessão, em tipos simples:
|
|
uint32_t session_id; ///< opcional, se tiveres um ID
|
|
uint32_t duration_s; ///< duração em segundos (0 no STARTED)
|
|
uint32_t energy_wh; ///< energia em Wh (0 no STARTED)
|
|
uint32_t avg_power_w; ///< potência média em W (0 no STARTED)
|
|
|
|
bool is_current; ///< true se ainda estiver em curso
|
|
} evse_session_event_data_t;
|
|
|
|
|
|
// -----------------
|
|
// Eventos de CONFIG
|
|
// -----------------
|
|
typedef struct {
|
|
bool charging; // Estado de carregamento
|
|
float hw_max_current; // Corrente máxima suportada pelo hardware
|
|
float runtime_current; // Corrente de carregamento em uso
|
|
int64_t timestamp_us; // Momento da atualização
|
|
} evse_config_event_data_t;
|
|
|
|
// Eventos simples e específicos
|
|
typedef struct {
|
|
bool enabled; // novo estado de enabled
|
|
int64_t timestamp_us; // epoch micros
|
|
} evse_enable_event_data_t;
|
|
|
|
typedef struct {
|
|
bool available; // novo estado de available
|
|
int64_t timestamp_us; // epoch micros
|
|
} evse_available_event_data_t;
|
|
|
|
#endif // EVSE_EVENTS_H
|