This commit is contained in:
2025-08-24 11:17:48 +01:00
parent 0d0dc5b129
commit 96b2ab1f57
31 changed files with 2883 additions and 4054 deletions

View File

@@ -1,8 +1,9 @@
set(srcs
"src/ocpp_events.c"
"src/ocpp.c"
)
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "include"
PRIV_REQUIRES nvs_flash
REQUIRES config esp_wifi evse mongoose MicroOcpp MicroOcppMongoose)
REQUIRES esp_event config esp_wifi evse mongoose MicroOcpp MicroOcppMongoose)

View File

@@ -4,41 +4,35 @@
#include <stdint.h>
#include <stdbool.h>
/**
* @brief Start ocpp
*/
void ocpp_start();
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Stop ocpp
*
* @brief Start OCPP
*/
void ocpp_start(void);
/**
* @brief Stop OCPP
*/
void ocpp_stop(void);
/* Config getters / setters */
bool ocpp_get_enabled(void);
void ocpp_get_server(char *value);
void ocpp_get_rfid(char *value);
void ocpp_set_enabled(bool value);
void ocpp_get_server(char *value); // buffer >= 64
void ocpp_set_server(char *value);
void ocpp_set_rfid(char *value);
void ocpp_get_charge_id(char *value); // buffer >= 64
void ocpp_set_charge_id(char *value);
void ocpp_begin_transaction(char *value);
/* Estado de conexão */
bool ocpp_is_connected(void);
void ocpp_end_transaction(char *value);
void ocpp_begin_transaction_authorized(char *value);
void ocpp_end_transaction_authorized(char *value);
bool ocpp_is_TransactionActive();
void ocpp_set_plugged(bool value);
void ocpp_set_charging(bool value);
#ifdef __cplusplus
}
#endif
#endif /* OCPP_H_ */

View File

@@ -0,0 +1,53 @@
#pragma once
#include "esp_event.h"
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Base de eventos do OCPP (igual ao padrão usado em auth_events.h) */
ESP_EVENT_DECLARE_BASE(OCPP_EVENTS);
/* IDs de eventos do OCPP */
typedef enum {
OCPP_EVENT_CONNECTED = 0, // payload: const char* (server URL) opcional
OCPP_EVENT_DISCONNECTED, // payload: NULL
OCPP_EVENT_AUTHORIZED, // payload: ocpp_idtag_event_t (opcional)
OCPP_EVENT_AUTH_REJECTED, // payload: ocpp_idtag_event_t (opcional)
OCPP_EVENT_AUTH_TIMEOUT, // payload: NULL
OCPP_EVENT_REMOTE_START, // payload: ocpp_idtag_event_t (opcional)
OCPP_EVENT_REMOTE_STOP, // payload: NULL
OCPP_EVENT_START_TX, // payload: ocpp_tx_event_t (opcional)
OCPP_EVENT_STOP_TX, // payload: ocpp_reason_event_t (opcional)
OCPP_EVENT_RESET, // payload: NULL
OCPP_EVENT_OPERATIVE_UPDATED
} ocpp_event_id_t;
/* Limites de strings simples (evita dependência de auth.h) */
#define OCPP_IDTAG_MAX 32
#define OCPP_REASON_MAX 32
/* Payloads opcionais */
typedef struct {
char idTag[OCPP_IDTAG_MAX];
} ocpp_idtag_event_t;
typedef struct {
int tx_id; // se disponível
} ocpp_tx_event_t;
typedef struct {
char reason[OCPP_REASON_MAX];
} ocpp_reason_event_t;
// Payload do novo evento
typedef struct {
bool operative; // true = Operative, false = Inoperative
int64_t timestamp_us; // esp_timer_get_time()
} ocpp_operative_event_t;
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
#include "ocpp_events.h"
/* Define a base, como em components/auth/src/auth_events.c */
ESP_EVENT_DEFINE_BASE(OCPP_EVENTS);