// === Início de: components/evse_link/include/evse_link.h ===
#ifndef EVSE_LINK_H_
#define EVSE_LINK_H_

#include <stdbool.h>
#include <stdint.h>

// Operation mode: slave or master
typedef enum {
    EVSE_LINK_MODE_SLAVE = 0,
    EVSE_LINK_MODE_MASTER = 1
} evse_link_mode_t;

// Callback invoked when a complete frame is received:
//   src:     device address of sender (0–255)
//   dest:    device address of receiver (0–255 or 0xFF broadcast)
//   payload: pointer to received data buffer (command + data)
//   len:     length of payload (0–255)
typedef void (*evse_link_rx_cb_t)(uint8_t src, uint8_t dest,
                                  const uint8_t *payload, uint8_t len);

// Initializes the EVSE-Link component
void evse_link_init(void);

// Sends a framed payload to `dest` with length `len`.
// The source address is automatically set from configuration.
// Returns true on successful enqueue/transmit.
bool evse_link_send(uint8_t dest, const uint8_t *payload, uint8_t len);

// Feeds a received byte into the framing parser.
void evse_link_recv_byte(uint8_t byte);

// Registers a callback to receive complete frames.
void evse_link_register_rx_cb(evse_link_rx_cb_t cb);

// Runtime configuration getters/setters
void              evse_link_set_mode(evse_link_mode_t mode);
evse_link_mode_t  evse_link_get_mode(void);

void evse_link_set_self_id(uint8_t id);
uint8_t evse_link_get_self_id(void);

void evse_link_set_enabled(bool enabled);
bool evse_link_is_enabled(void);

#endif // EVSE_LINK_H_

// === Fim de: components/evse_link/include/evse_link.h ===
