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>
29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "cJSON.h"
|
|
|
|
// Native binary (v2) driver envelope, byte-compatible with
|
|
// src/util/binary_envelope.py. Presets and select entries go in separate
|
|
// frames so each frame is 5 + blob <= ENV_FRAME_MAX (one ESP-NOW payload).
|
|
#define ENV_FRAME_MAX 224 // + 4C 04 <group> wrapper must fit REL_FRAG_MAX
|
|
#define ENV_BLOB_MAX (ENV_FRAME_MAX - 5)
|
|
|
|
typedef struct {
|
|
uint8_t data[ENV_BLOB_MAX + 1]; // data[0] is the entry count
|
|
size_t len;
|
|
} env_blob_t;
|
|
|
|
void env_blob_init(env_blob_t *b);
|
|
|
|
// Append one preset (short keys p,c,d,b,a,n1..n6 or long pattern/colors/...); false if it does not fit
|
|
bool env_add_preset(env_blob_t *b, const char *name, const cJSON *preset);
|
|
// Append one select entry; step < 0 means none
|
|
bool env_add_select(env_blob_t *b, const char *device, const char *preset, int step);
|
|
|
|
// Frame with either a presets blob or a select blob (the other empty);
|
|
// brightness < 0 leaves device brightness unchanged. Returns frame length.
|
|
size_t env_frame(uint8_t *out, int brightness, const env_blob_t *presets, const env_blob_t *select);
|