feat(v2): ESP32-S3 controller with Ethernet, I2S mic beat detection and ESP-NOW
New ESP-IDF project in v2/ that replaces the Pi and the UART bridge: - W5500 Ethernet, INMP441 beat/tempo detector (from esp32-eth), ESP-NOW master - LittleFS data store and a JSON API over the Pi's db/*.json collections, with /db import and export; web UI minified and gzipped at build time - Zone play/stop as 0x4C GROUP_CMD, preset push/send as CMD (binary v2 envelope, byte-identical to src/util/binary_envelope.py), sequencer and scenes, driver registration from the boot hello - Reliable bulk link: acks with retransmit, fragments, state-version digest and resync; beat frames sent twice with a lead so drivers fire together - Bench tooling: lossy-link mode, synthetic beats with echo measurement, USB and logic-analyzer latency scripts, and docs/BENCH_TEST.md Needs the matching led-driver changes (p2p branch) to receive the link and beat frames. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7336c7fb22
commit
a94d6a7de5
37 files changed
+5109
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "beat.h"
|
||||
|
||||
// Beat frame, broadcast. Little endian, 8 bytes.
|
||||
#define BEAT_FRAME_MAGIC 0x4C // 0x4C wire protocol, message type 0x25
|
||||
#define BEAT_FRAME_TYPE 0x25
|
||||
#define BEAT_FLAG_DOWNBEAT 0x01
|
||||
#define BEAT_FLAG_BAR_SHIFT 1 // bits 1-3: bar position 0..7 (0 = unknown)
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint8_t magic;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
uint16_t beat_idx; // same for every copy of one beat
|
||||
uint16_t period_ms; // beat period, drivers free-run on it
|
||||
uint8_t fire_in_ms; // drivers fire this long after receipt
|
||||
} beat_frame_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t beats_sent;
|
||||
uint32_t beat_send_fail;
|
||||
uint32_t bulk_sent;
|
||||
uint32_t bulk_retries;
|
||||
uint32_t bulk_failed;
|
||||
uint32_t sim_dropped; // frames discarded by the lossy-link test mode
|
||||
} espnow_stats_t;
|
||||
|
||||
// Start Wi-Fi (no AP) on the configured channel and ESP-NOW; hooks beat_set_callback
|
||||
esp_err_t espnow_tx_init(void);
|
||||
|
||||
// Queue a bulk frame (<= 240 bytes). mac NULL broadcasts. Unicast frames are
|
||||
// retried; they never go out within the hold-off window after a beat.
|
||||
esp_err_t espnow_tx_send(const uint8_t *mac, const void *data, size_t len);
|
||||
|
||||
void espnow_tx_stats(espnow_stats_t *out);
|
||||
|
||||
// Send one beat now (also used by the bench generator). bar 0 = unknown.
|
||||
void espnow_tx_beat(float bpm, bool downbeat, int bar);
|
||||
|
||||
// Lossy-link test mode: discard this percentage of outgoing frames and of
|
||||
// received acks/echoes. include_beats = false leaves beat copies alone.
|
||||
void espnow_tx_set_loss(int percent, bool include_beats);
|
||||
int espnow_tx_loss(bool *include_beats);
|
||||
bool espnow_tx_drop(void);
|
||||
Reference in new issue
Block a user