#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
