- espnow_link, ctrl_msg and beat_sync: the reliable link, envelopes and beat-synced timing. - ctrl_msg: accept an envelope with the trailing save byte. - patterns_frame() and espnow_link_poll() split out of their tasks, so the WebAssembly simulator can drive one frame and one link pass from a timer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
/*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* ESP-NOW link to led-controller: the 0x4C wire protocol the MicroPython drivers speak. The driver announces
|
|
* itself at boot, takes the controller's reliable messages (acked, reassembled, deduplicated, resynced by
|
|
* digest), answers pings, and passes everything else to ctrl_msg. Beats set the tempo (beat_sync).
|
|
*/
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include "esp_err.h"
|
|
|
|
typedef struct {
|
|
bool running;
|
|
uint8_t channel;
|
|
bool master_seen;
|
|
uint8_t master[6];
|
|
uint32_t msgs; // reliable messages delivered
|
|
uint32_t dups; // duplicate fragments of a message already delivered
|
|
uint32_t acks;
|
|
uint32_t resyncs;
|
|
uint32_t pings;
|
|
uint32_t beats;
|
|
uint32_t dropped; // frames lost to a full inbox
|
|
uint32_t frames; // every ESP-NOW frame the radio delivered
|
|
uint32_t sent;
|
|
uint32_t send_fail;
|
|
uint16_t ver; // state version of the last committed message
|
|
} espnow_stats_t;
|
|
|
|
/** @brief Start ESP-NOW and the link task, if enabled in settings. Call after net_start(). */
|
|
esp_err_t espnow_link_start(void);
|
|
|
|
/** @brief One pass of the link without waiting: the received frames, then the timed sends. The link task runs it
|
|
* in a loop; a build without that task (the browser simulator) calls it from a timer. */
|
|
void espnow_link_poll(void);
|
|
|
|
/** @brief Copy the link's counters and state. */
|
|
void espnow_link_stats(espnow_stats_t *out);
|