Add BMA456 tap detection with ESP-NOW notify and host snapshot API.

Slaves forward configured tap kinds to the master; goTool exposes CLI, dashboard, REST, and WebSocket with separate notify vs receive and 2s display cache.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-29 20:42:57 +02:00
co-authored by Cursor
parent 3cb0b5bbe9
commit a8d4d42920
34 changed files with 3138 additions and 241 deletions
+35
View File
@@ -30,6 +30,14 @@ typedef struct {
uint32_t accel_updated_at;
/** Host-enabled ESP-NOW accel stream to master. */
bool accel_stream_enabled;
/** Host-enabled ESP-NOW tap notify flags. */
bool tap_notify_single;
bool tap_notify_double;
bool tap_notify_triple;
/** Latest tap from slave ESP-NOW (master only, short-lived cache). */
bool tap_valid;
uint32_t tap_kind;
uint32_t tap_updated_at;
/** Latest LiPo ADC from slave ESP-NOW battery report (~30 s). */
bool lipo1_valid;
bool lipo2_valid;
@@ -39,6 +47,8 @@ typedef struct {
} client_info_t;
#define CLIENT_REGISTRY_DEFAULT_ACCEL_DEADZONE 100u
/** Tap events older than this are discarded (matches accel stream interval). */
#define CLIENT_REGISTRY_TAP_MAX_AGE_MS 16u
void client_registry_init(void);
@@ -87,6 +97,31 @@ esp_err_t client_registry_set_accel_stream(uint32_t client_id, bool enabled);
esp_err_t client_registry_get_accel_stream(uint32_t client_id, bool *enabled_out);
size_t client_registry_set_accel_stream_all(bool enabled);
esp_err_t client_registry_set_tap_notify(uint32_t client_id, bool single,
bool double_tap, bool triple);
esp_err_t client_registry_get_tap_notify(uint32_t client_id, bool *single_out,
bool *double_tap_out,
bool *triple_out);
size_t client_registry_set_tap_notify_all(bool single, bool double_tap,
bool triple);
/** Store tap event from slave (matched by sender MAC). kind: 1=single, 2=double, 3=triple. */
esp_err_t client_registry_update_tap(const uint8_t mac[CLIENT_MAC_LEN],
uint32_t slave_id, uint32_t kind);
/** Drop cached tap if older than CLIENT_REGISTRY_TAP_MAX_AGE_MS. */
void client_registry_expire_tap(client_info_t *info);
/** Clear cached tap after UART snapshot or expiry. */
void client_registry_clear_tap(client_info_t *info);
/**
* If client has a fresh tap (age <= CLIENT_REGISTRY_TAP_MAX_AGE_MS), copy it out
* and clear the cache. Returns true when an event was returned.
*/
bool client_registry_take_tap(uint32_t client_id, uint32_t *kind_out,
uint32_t *age_ms_out);
/** Master local LiPo (client_id 0 in UART battery responses). */
void client_registry_set_master_battery(const board_lipo_reading_t *reading);
bool client_registry_get_master_battery(board_lipo_reading_t *reading_out,