Files
chargeflow/components/evse_link/include/evse_link.h
2025-08-05 16:55:11 +01:00

46 lines
1.4 KiB
C
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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 (0255)
// dest: device address of receiver (0255 or 0xFF broadcast)
// payload: pointer to received data buffer (command + data)
// len: length of payload (0255)
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_