Expose best_effort/fast/wait/reliable via UART, dashboard, and CLI so loss vs latency can be compared under real multi-pod load. Co-authored-by: Cursor <cursoragent@cursor.com>
95 lines
4.1 KiB
C
95 lines
4.1 KiB
C
#ifndef ESP_NOW_COMM_H
|
|
#define ESP_NOW_COMM_H
|
|
|
|
#include "app_config.h"
|
|
#include "client_registry.h"
|
|
#include "esp_err.h"
|
|
#include "esp_now_messages.pb.h"
|
|
#include "uart_messages.pb.h"
|
|
|
|
esp_err_t esp_now_comm_init(const app_config_t *config);
|
|
|
|
/** Master: enable/disable accel ESP-NOW stream on one slave. */
|
|
esp_err_t esp_now_comm_send_accel_stream(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id, bool enable);
|
|
|
|
/** Master: set accel/tap ESP-NOW send path on one slave (InputSendMode). */
|
|
esp_err_t esp_now_comm_send_input_send_mode(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id, uint32_t mode);
|
|
|
|
/** Master: configure tap notify flags on one slave. */
|
|
esp_err_t esp_now_comm_send_tap_notify(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id, bool single,
|
|
bool double_tap, bool triple);
|
|
|
|
/** Master: unicast accel deadzone to one slave (client_id is echoed for filtering). */
|
|
esp_err_t esp_now_comm_send_accel_deadzone(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id, uint32_t deadzone);
|
|
|
|
/** Master: unicast BMA456 tap config to one slave. */
|
|
esp_err_t esp_now_comm_send_tap_config(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id,
|
|
const bma456_tap_config_t *cfg);
|
|
|
|
/** Master: send minimal unicast test payload to verify master→slave path. */
|
|
esp_err_t esp_now_comm_send_unicast_test(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t seq);
|
|
|
|
/** Result of a master-side ESP-NOW echo ping round-trip. */
|
|
typedef struct {
|
|
uint64_t echoed_us;
|
|
uint32_t esp_rtt_us;
|
|
} esp_now_echo_ping_result_t;
|
|
|
|
/** Master: ESP-NOW echo ping round-trip; fills result on success. */
|
|
esp_err_t esp_now_comm_echo_ping(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint64_t timestamp_us,
|
|
esp_now_echo_ping_result_t *result);
|
|
|
|
/** Master: trigger find-me LED sequence on one slave. */
|
|
esp_err_t esp_now_comm_send_find_me(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id);
|
|
|
|
/** Master: LED ring command on one slave. */
|
|
esp_err_t esp_now_comm_send_led_ring(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id,
|
|
const alox_LedRingProgressRequest *req);
|
|
|
|
/** Master: request reboot on one slave. */
|
|
esp_err_t esp_now_comm_send_restart(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t client_id);
|
|
|
|
/** Master: tell slave its assigned logical client id. */
|
|
esp_err_t esp_now_comm_send_assign_id(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t assigned_id);
|
|
|
|
/** Master: tell slave to forget persisted master/id binding. */
|
|
esp_err_t esp_now_comm_send_clear_id_binding(const uint8_t mac[CLIENT_MAC_LEN]);
|
|
|
|
/**
|
|
* Master: clear NVS id map + live registry and unicast CLEAR_ID_BINDING to
|
|
* every currently registered live slave (snapshot before clear).
|
|
*/
|
|
esp_err_t esp_now_comm_reset_client_id_map(void);
|
|
|
|
/** Slave: clear local NVS master/id binding (UART reset on slave). */
|
|
esp_err_t esp_now_comm_clear_local_id_binding(void);
|
|
|
|
/** Master → slave OTA (unicast). */
|
|
esp_err_t esp_now_comm_send_ota_start(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t total_size);
|
|
esp_err_t esp_now_comm_send_ota_payload(const uint8_t mac[CLIENT_MAC_LEN],
|
|
uint32_t seq, const uint8_t *data,
|
|
size_t len);
|
|
esp_err_t esp_now_comm_send_ota_end(const uint8_t mac[CLIENT_MAC_LEN]);
|
|
|
|
/** Slave → master OTA status. */
|
|
esp_err_t esp_now_comm_send_ota_status(const uint8_t master_mac[CLIENT_MAC_LEN],
|
|
uint32_t status, uint32_t bytes_written,
|
|
uint32_t error);
|
|
|
|
/** Slave: MAC of joined master (false if not joined). */
|
|
bool esp_now_comm_get_master_mac(uint8_t mac_out[CLIENT_MAC_LEN]);
|
|
|
|
#endif
|