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:
@@ -20,6 +20,8 @@ idf_component_register(
|
||||
"cmd/cmd_accel_deadzone.c"
|
||||
"cmd/cmd_accel_snapshot.c"
|
||||
"cmd/cmd_accel_stream.c"
|
||||
"cmd/cmd_tap_notify.c"
|
||||
"cmd/cmd_tap_snapshot.c"
|
||||
"cmd/cmd_espnow_unicast_test.c"
|
||||
"cmd/cmd_espnow_find_me.c"
|
||||
"cmd/cmd_restart.c"
|
||||
|
||||
+54
-1
@@ -116,6 +116,8 @@ Schema: `proto/esp_now_messages.proto`. Encode/decode: `esp_now_proto.c`. The ES
|
||||
| `ESPNOW_FIND_ME` | Master → slave | `EspNowFindMe` (`client_id` filter) — LED locate sequence |
|
||||
| `ESPNOW_RESTART` | Master → slave | `EspNowRestart` (`client_id` filter) — reboot slave |
|
||||
| `ESPNOW_ACCEL_SAMPLE` | Slave → master | `EspNowAccelSample` (`slave_id`, `x`, `y`, `z` raw LSB) — ~every 16 ms |
|
||||
| `ESPNOW_SET_TAP_NOTIFY` | Master → slave | `EspNowTapNotify` (`client_id`, `single`, `double_tap`, `triple`) — which tap kinds to forward |
|
||||
| `ESPNOW_TAP_EVENT` | Slave → master | `EspNowTapEvent` (`client_id`, `kind`) — on BMA456 tap interrupt if notify enabled |
|
||||
| `ESPNOW_BATTERY_REPORT` | Slave → master | `EspNowBatteryReport` (`client_id`, `lipo1/2` mV) — ~every 30 s; cached in `client_registry` |
|
||||
| `ESPNOW_OTA_START` | Master → slave (unicast) | `EspNowOtaStart` (`total_size`) |
|
||||
| `ESPNOW_OTA_PAYLOAD` | Master → slave | `EspNowOtaPayload` (`seq`, up to 200 B `data`) |
|
||||
@@ -221,6 +223,8 @@ Host and master speak nanopb-encoded `UartMessage` inside UART frames (byte 0 =
|
||||
| 22 | `FIND_ME` | Implemented (`cmd/cmd_espnow_find_me.c`) — `client_id=0` local ring, `>0` ESP-NOW to slave |
|
||||
| 23 | `RESTART` | Implemented (`cmd/cmd_restart.c`) — `client_id=0` reboot master, `>0` ESP-NOW reboot slave |
|
||||
| 24 | `ACCEL_SNAPSHOT` | Implemented (`cmd/cmd_accel_snapshot.c`) — cached slave accel from ESP-NOW stream |
|
||||
| 27 | `TAP_NOTIFY` | Implemented (`cmd/cmd_tap_notify.c`) — get/set which tap kinds notify via ESP-NOW |
|
||||
| 28 | `TAP_SNAPSHOT` | Implemented (`cmd/cmd_tap_snapshot.c`) — consume cached tap events from master registry |
|
||||
|
||||
Regenerate C code:
|
||||
|
||||
@@ -337,6 +341,52 @@ go run . -port /dev/ttyUSB0 accel
|
||||
|
||||
External API (`serve -api-addr :8081`) polls this command every 16 ms and streams JSON over WebSocket.
|
||||
|
||||
### TAP_NOTIFY command
|
||||
|
||||
Configure which BMA456 tap kinds a **slave** forwards to the master over ESP-NOW. The slave only sends `ESPNOW_TAP_EVENT` when the matching notify flag is enabled (set locally on the slave via ESP-NOW).
|
||||
|
||||
**Request:** framed `1b` (`0x1b`) + `tap_notify_request`:
|
||||
|
||||
| Field | Meaning |
|
||||
|-------|---------|
|
||||
| `write` | `false` = read, `true` = write |
|
||||
| `single`, `double_tap`, `triple` | Which tap kinds to notify (write) |
|
||||
| `client_id` | Slave id (read/write one slave) |
|
||||
| `all_clients` | Master: ESP-NOW unicast to every registered slave |
|
||||
|
||||
**Response:** `tap_notify_response` (`client_id`, `success`, `slaves_updated`, `single`, `double_tap`, `triple`).
|
||||
|
||||
Notify flags are mirrored in `ClientInfo` (`tap_notify_single/double/triple`) for the dashboard.
|
||||
|
||||
```bash
|
||||
go run . -port /dev/ttyUSB0 tap-notify -client 16 -set -single
|
||||
go run . -port /dev/ttyUSB0 tap-notify -client 16
|
||||
```
|
||||
|
||||
### TAP_SNAPSHOT command
|
||||
|
||||
Read **cached** tap events on the **master** (one pending event per slave). Slaves send `ESPNOW_TAP_EVENT` on tap; the master stores the latest value per client in `client_registry.c` for up to **16 ms** (`CLIENT_REGISTRY_TAP_MAX_AGE_MS`). Each snapshot **consumes** fresh events (cleared after read).
|
||||
|
||||
Only slaves with at least one tap-notify flag enabled are included.
|
||||
|
||||
**Request:** framed `1c` (`0x1c`) + optional `tap_snapshot_request` (`client_id`: `0` = all, `>0` = one id).
|
||||
|
||||
**Response:** `tap_snapshot_response.events[]`:
|
||||
|
||||
| Field | Meaning |
|
||||
|-------|---------|
|
||||
| `client_id` | Slave id (registry) |
|
||||
| `valid` | Fresh tap available (≤16 ms) |
|
||||
| `kind` | `TAP_SINGLE`, `TAP_DOUBLE`, or `TAP_TRIPLE` |
|
||||
| `age_ms` | Ms since tap was received on master |
|
||||
|
||||
Host tools poll this only when **receive** is enabled (dashboard tap column, WebSocket `set_tap_stream`). They keep events visible for **2 s** in the UI/API after first sight.
|
||||
|
||||
```bash
|
||||
go run . -port /dev/ttyUSB0 tap
|
||||
go run . -port /dev/ttyUSB0 tap -client 16
|
||||
```
|
||||
|
||||
### ESPNOW_UNICAST_TEST command
|
||||
|
||||
Minimal master→slave ESP-NOW unicast check (no BMA456). Use this before debugging `ACCEL_DEADZONE` unicast.
|
||||
@@ -424,7 +474,7 @@ go run . -port /dev/ttyUSB0 led-ring -mode digit -digit 5 -all
|
||||
|
||||
**Response:** payload `04` + nanopb `UartMessage` with `client_info_response.clients` — one `ClientInfo` per registered slave (from ESP-NOW `SLAVE_INFO`).
|
||||
|
||||
Fields per client: `id`, `mac`, `version`, `available`, `used`, `last_ping`, `last_success_ping` — **milliseconds since** the last packet / last successful heartbeat (computed when `CLIENT_INFO` is answered; typically 0–1000 while the slave is heartbeating every 1 s).
|
||||
Fields per client: `id`, `mac`, `version`, `available`, `used`, `last_ping`, `last_success_ping`, `tap_notify_single`, `tap_notify_double`, `tap_notify_triple` — **milliseconds since** the last packet / last successful heartbeat (computed when `CLIENT_INFO` is answered; typically 0–1000 while the slave is heartbeating every 1 s).
|
||||
|
||||
## Client registry
|
||||
|
||||
@@ -435,6 +485,7 @@ Fields per client: `id`, `mac`, `version`, `available`, `used`, `last_ping`, `la
|
||||
| `client_registry_heartbeat(mac, id, version, …)` | Same as upsert for heartbeats; reactivates inactive clients |
|
||||
| `client_registry_check_timeouts(timeout_ms)` | Mark stale clients inactive (master monitor task) |
|
||||
| `client_registry_count()` / `client_registry_at(i)` | Iterate for UART encoding |
|
||||
| `client_registry_set_tap_notify()` / `client_registry_take_tap()` | Tap notify flags + short-lived tap cache (16 ms) |
|
||||
|
||||
Slaves register when the master receives `SLAVE_INFO` on the matching network; `HEARTBEAT` keeps them marked available. The registry **MAC is always the ESP-NOW source address** (`recv_info.src_addr`), not the optional `mac` bytes in the protobuf (used only on the wire for debugging).
|
||||
|
||||
@@ -502,6 +553,8 @@ Target: ESP32-S3. Close serial monitor on the UART adapter port before running `
|
||||
| `client_registry.c/h` | Registered slave table |
|
||||
| `bosch456.c/h` | BMA456H I2C driver, accel poll, on-demand read, tap INT, deadzone filter |
|
||||
| `cmd/cmd_accel_snapshot.c` | UART `ACCEL_SNAPSHOT` — cached slave accel |
|
||||
| `cmd/cmd_tap_notify.c` | UART `TAP_NOTIFY` — ESP-NOW tap notify config |
|
||||
| `cmd/cmd_tap_snapshot.c` | UART `TAP_SNAPSHOT` — consume cached tap events |
|
||||
| `board_input.c/h` | Taster GPIO12, LiPo ADC on GPIO1 / GPIO12 |
|
||||
| `pod_settings.c/h` | NVS persistence (accel deadzone, …) |
|
||||
| `led_ring.c/h` | LED ring (digit display, progress bar) |
|
||||
|
||||
@@ -36,6 +36,8 @@ static bool s_have_last_sample;
|
||||
|
||||
static volatile bool s_int_pending;
|
||||
static SemaphoreHandle_t s_accel_mutex;
|
||||
static bma456_tap_handler_t s_tap_handler;
|
||||
static void *s_tap_handler_ctx;
|
||||
|
||||
static esp_err_t check_bma4(const char *api_name, int8_t rslt);
|
||||
|
||||
@@ -123,6 +125,11 @@ void bma456_set_accel_deadzone(uint32_t deadzone_lsb) {
|
||||
|
||||
uint32_t bma456_get_accel_deadzone(void) { return s_accel_deadzone; }
|
||||
|
||||
void bma456_set_tap_handler(bma456_tap_handler_t handler, void *ctx) {
|
||||
s_tap_handler = handler;
|
||||
s_tap_handler_ctx = ctx;
|
||||
}
|
||||
|
||||
esp_err_t bma456_read_accel(int16_t *x, int16_t *y, int16_t *z) {
|
||||
if (!s_bma456_ready || x == NULL || y == NULL || z == NULL) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -183,10 +190,19 @@ static void handle_tap_interrupt(void) {
|
||||
|
||||
if (tap_out.single_tap) {
|
||||
ESP_LOGI(TAG, "tap: single");
|
||||
if (s_tap_handler != NULL) {
|
||||
s_tap_handler(BMA456_TAP_SINGLE, s_tap_handler_ctx);
|
||||
}
|
||||
} else if (tap_out.double_tap) {
|
||||
ESP_LOGI(TAG, "tap: double");
|
||||
if (s_tap_handler != NULL) {
|
||||
s_tap_handler(BMA456_TAP_DOUBLE, s_tap_handler_ctx);
|
||||
}
|
||||
} else if (tap_out.triple_tap) {
|
||||
ESP_LOGI(TAG, "tap: triple");
|
||||
if (s_tap_handler != NULL) {
|
||||
s_tap_handler(BMA456_TAP_TRIPLE, s_tap_handler_ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,18 @@ uint32_t bma456_get_accel_deadzone(void);
|
||||
/** Log accel when any axis moved more than deadzone since last reported sample. */
|
||||
void bma456_report_accel_if_changed(int16_t x, int16_t y, int16_t z);
|
||||
|
||||
/** Tap kinds from BMA456H multitap output. */
|
||||
typedef enum {
|
||||
BMA456_TAP_SINGLE = 1,
|
||||
BMA456_TAP_DOUBLE = 2,
|
||||
BMA456_TAP_TRIPLE = 3,
|
||||
} bma456_tap_kind_t;
|
||||
|
||||
typedef void (*bma456_tap_handler_t)(bma456_tap_kind_t kind, void *ctx);
|
||||
|
||||
/** Optional callback invoked from sensor task on tap interrupt (may be NULL). */
|
||||
void bma456_set_tap_handler(bma456_tap_handler_t handler, void *ctx);
|
||||
|
||||
/** On-demand read of current accel XYZ (raw LSB). Returns ESP_ERR_INVALID_STATE if sensor not ready. */
|
||||
esp_err_t bma456_read_accel(int16_t *x, int16_t *y, int16_t *z);
|
||||
|
||||
|
||||
@@ -257,6 +257,31 @@ static void clear_client_accel(client_slot_t *slot) {
|
||||
slot->info.accel_updated_at = 0;
|
||||
}
|
||||
|
||||
static void clear_client_tap(client_slot_t *slot) {
|
||||
if (slot == NULL) {
|
||||
return;
|
||||
}
|
||||
slot->info.tap_valid = false;
|
||||
slot->info.tap_kind = 0;
|
||||
slot->info.tap_updated_at = 0;
|
||||
}
|
||||
|
||||
static bool tap_kind_enabled(const client_info_t *info, uint32_t kind) {
|
||||
if (info == NULL) {
|
||||
return false;
|
||||
}
|
||||
switch (kind) {
|
||||
case 1:
|
||||
return info->tap_notify_single;
|
||||
case 2:
|
||||
return info->tap_notify_double;
|
||||
case 3:
|
||||
return info->tap_notify_triple;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t client_registry_set_accel_stream(uint32_t client_id, bool enabled) {
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
if (!s_clients[i].active || s_clients[i].info.id != client_id) {
|
||||
@@ -325,6 +350,124 @@ esp_err_t client_registry_update_accel(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_set_tap_notify(uint32_t client_id, bool single,
|
||||
bool double_tap, bool triple) {
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
if (!s_clients[i].active || s_clients[i].info.id != client_id) {
|
||||
continue;
|
||||
}
|
||||
s_clients[i].info.tap_notify_single = single;
|
||||
s_clients[i].info.tap_notify_double = double_tap;
|
||||
s_clients[i].info.tap_notify_triple = triple;
|
||||
if (!single && !double_tap && !triple) {
|
||||
clear_client_tap(&s_clients[i]);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_get_tap_notify(uint32_t client_id, bool *single_out,
|
||||
bool *double_tap_out,
|
||||
bool *triple_out) {
|
||||
if (single_out == NULL || double_tap_out == NULL || triple_out == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
const client_info_t *info = client_registry_find_by_id(client_id);
|
||||
if (info == NULL) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
*single_out = info->tap_notify_single;
|
||||
*double_tap_out = info->tap_notify_double;
|
||||
*triple_out = info->tap_notify_triple;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
size_t client_registry_set_tap_notify_all(bool single, bool double_tap,
|
||||
bool triple) {
|
||||
size_t n = 0;
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
if (!s_clients[i].active) {
|
||||
continue;
|
||||
}
|
||||
s_clients[i].info.tap_notify_single = single;
|
||||
s_clients[i].info.tap_notify_double = double_tap;
|
||||
s_clients[i].info.tap_notify_triple = triple;
|
||||
if (!single && !double_tap && !triple) {
|
||||
clear_client_tap(&s_clients[i]);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
esp_err_t client_registry_update_tap(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t slave_id, uint32_t kind) {
|
||||
if (mac == NULL || kind < 1 || kind > 3) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
client_slot_t *slot = find_slot(mac);
|
||||
if (slot == NULL) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
if (slot->info.id != slave_id) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (!tap_kind_enabled(&slot->info, kind)) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
slot->info.tap_kind = kind;
|
||||
slot->info.tap_valid = true;
|
||||
slot->info.tap_updated_at = now_ms();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void client_registry_expire_tap(client_info_t *info) {
|
||||
if (info == NULL || !info->tap_valid) {
|
||||
return;
|
||||
}
|
||||
if (client_registry_ms_since(info->tap_updated_at) >
|
||||
CLIENT_REGISTRY_TAP_MAX_AGE_MS) {
|
||||
info->tap_valid = false;
|
||||
info->tap_kind = 0;
|
||||
info->tap_updated_at = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void client_registry_clear_tap(client_info_t *info) {
|
||||
if (info == NULL) {
|
||||
return;
|
||||
}
|
||||
info->tap_valid = false;
|
||||
info->tap_kind = 0;
|
||||
info->tap_updated_at = 0;
|
||||
}
|
||||
|
||||
bool client_registry_take_tap(uint32_t client_id, uint32_t *kind_out,
|
||||
uint32_t *age_ms_out) {
|
||||
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
|
||||
if (!s_clients[i].active || s_clients[i].info.id != client_id) {
|
||||
continue;
|
||||
}
|
||||
client_info_t *info = &s_clients[i].info;
|
||||
client_registry_expire_tap(info);
|
||||
if (!info->tap_valid) {
|
||||
return false;
|
||||
}
|
||||
if (kind_out != NULL) {
|
||||
*kind_out = info->tap_kind;
|
||||
}
|
||||
if (age_ms_out != NULL) {
|
||||
*age_ms_out = client_registry_ms_since(info->tap_updated_at);
|
||||
}
|
||||
client_registry_clear_tap(info);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void client_registry_set_master_battery(const board_lipo_reading_t *reading) {
|
||||
if (reading == NULL) {
|
||||
return;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -28,6 +28,9 @@ static bool encode_clients_list(pb_ostream_t *stream, const pb_field_t *field,
|
||||
client_registry_ms_since(client->last_success_ping_at);
|
||||
proto.version = client->version;
|
||||
proto.accel_stream_enabled = client->accel_stream_enabled;
|
||||
proto.tap_notify_single = client->tap_notify_single;
|
||||
proto.tap_notify_double = client->tap_notify_double;
|
||||
proto.tap_notify_triple = client->tap_notify_triple;
|
||||
proto.mac.funcs.encode = uart_cmd_encode_bytes;
|
||||
proto.mac.arg = &mac;
|
||||
|
||||
|
||||
@@ -54,6 +54,10 @@ static const char *message_type_name(uint16_t id) {
|
||||
return "ACCEL_STREAM";
|
||||
case alox_MessageType_BATTERY_STATUS:
|
||||
return "BATTERY_STATUS";
|
||||
case alox_MessageType_TAP_NOTIFY:
|
||||
return "TAP_NOTIFY";
|
||||
case alox_MessageType_TAP_SNAPSHOT:
|
||||
return "TAP_SNAPSHOT";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
#include "client_registry.h"
|
||||
#include "cmd_tap_notify.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "uart_cmd.h"
|
||||
|
||||
static const char *TAG = "[TAP_NOTIFY]";
|
||||
|
||||
static void reply(uint32_t client_id, bool success, uint32_t slaves_updated,
|
||||
bool single, bool double_tap, bool triple) {
|
||||
alox_UartMessage response;
|
||||
uart_cmd_init_response(&response, alox_MessageType_TAP_NOTIFY,
|
||||
alox_UartMessage_tap_notify_response_tag);
|
||||
response.payload.tap_notify_response.client_id = client_id;
|
||||
response.payload.tap_notify_response.success = success;
|
||||
response.payload.tap_notify_response.slaves_updated = slaves_updated;
|
||||
response.payload.tap_notify_response.single = single;
|
||||
response.payload.tap_notify_response.double_tap = double_tap;
|
||||
response.payload.tap_notify_response.triple = triple;
|
||||
uart_cmd_send(&response, TAG);
|
||||
}
|
||||
|
||||
static esp_err_t push_tap_notify_to_slave(const client_info_t *client,
|
||||
bool single, bool double_tap,
|
||||
bool triple) {
|
||||
if (client == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
esp_err_t err =
|
||||
client_registry_set_tap_notify(client->id, single, double_tap, triple);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
return esp_now_comm_send_tap_notify(client->mac, client->id, single,
|
||||
double_tap, triple);
|
||||
}
|
||||
|
||||
static void handle_tap_notify(const uint8_t *data, size_t len) {
|
||||
alox_UartMessage uart_msg;
|
||||
alox_TapNotifyRequest req = alox_TapNotifyRequest_init_zero;
|
||||
|
||||
if (uart_cmd_decode(data, len, &uart_msg) == ESP_OK) {
|
||||
const alox_TapNotifyRequest *req_ptr = UART_CMD_REQ(
|
||||
&uart_msg, alox_UartMessage_tap_notify_request_tag, tap_notify_request);
|
||||
if (req_ptr != NULL) {
|
||||
req = *req_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (req.write) {
|
||||
if (req.all_clients) {
|
||||
size_t n = client_registry_set_tap_notify_all(req.single, req.double_tap,
|
||||
req.triple);
|
||||
uint32_t sent = 0;
|
||||
|
||||
for (size_t i = 0; i < client_registry_count(); i++) {
|
||||
const client_info_t *client = client_registry_at(i);
|
||||
if (client == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (esp_now_comm_send_tap_notify(client->mac, client->id, req.single,
|
||||
req.double_tap,
|
||||
req.triple) == ESP_OK) {
|
||||
sent++;
|
||||
}
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "tap notify single=%d double=%d triple=%d for %u/%u slaves",
|
||||
req.single, req.double_tap, req.triple, (unsigned)sent,
|
||||
(unsigned)n);
|
||||
reply(0, sent > 0, sent, req.single, req.double_tap, req.triple);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.client_id == 0) {
|
||||
ESP_LOGW(TAG, "client_id required (or all_clients)");
|
||||
reply(0, false, 0, req.single, req.double_tap, req.triple);
|
||||
return;
|
||||
}
|
||||
|
||||
const client_info_t *client = client_registry_find_by_id(req.client_id);
|
||||
if (client == NULL) {
|
||||
ESP_LOGW(TAG, "client id %lu not found", (unsigned long)req.client_id);
|
||||
reply(req.client_id, false, 0, req.single, req.double_tap, req.triple);
|
||||
return;
|
||||
}
|
||||
|
||||
esp_err_t err =
|
||||
push_tap_notify_to_slave(client, req.single, req.double_tap, req.triple);
|
||||
reply(req.client_id, err == ESP_OK, err == ESP_OK ? 1u : 0u, req.single,
|
||||
req.double_tap, req.triple);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.all_clients || req.client_id == 0) {
|
||||
reply(0, false, 0, false, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
bool single = false;
|
||||
bool double_tap = false;
|
||||
bool triple = false;
|
||||
esp_err_t err = client_registry_get_tap_notify(req.client_id, &single,
|
||||
&double_tap, &triple);
|
||||
reply(req.client_id, err == ESP_OK, 0, single, double_tap, triple);
|
||||
}
|
||||
|
||||
void cmd_tap_notify_register(void) {
|
||||
uart_cmd_register(alox_MessageType_TAP_NOTIFY, handle_tap_notify);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef CMD_TAP_NOTIFY_H
|
||||
#define CMD_TAP_NOTIFY_H
|
||||
|
||||
void cmd_tap_notify_register(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "client_registry.h"
|
||||
#include "cmd_tap_snapshot.h"
|
||||
#include "uart_cmd.h"
|
||||
|
||||
static const char *TAG = "[TAP_SNAP]";
|
||||
|
||||
static alox_TapKind tap_kind_from_registry(uint32_t kind) {
|
||||
switch (kind) {
|
||||
case 1:
|
||||
return alox_TapKind_TAP_SINGLE;
|
||||
case 2:
|
||||
return alox_TapKind_TAP_DOUBLE;
|
||||
case 3:
|
||||
return alox_TapKind_TAP_TRIPLE;
|
||||
default:
|
||||
return alox_TapKind_TAP_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool tap_notify_any(const client_info_t *client) {
|
||||
return client != NULL &&
|
||||
(client->tap_notify_single || client->tap_notify_double ||
|
||||
client->tap_notify_triple);
|
||||
}
|
||||
|
||||
static void fill_tap_snapshot(alox_TapSnapshotResponse *out,
|
||||
uint32_t filter_client_id) {
|
||||
if (out == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
out->events_count = 0;
|
||||
size_t count = client_registry_count();
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const client_info_t *client = client_registry_at(i);
|
||||
if (client == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (filter_client_id != 0 && client->id != filter_client_id) {
|
||||
continue;
|
||||
}
|
||||
if (!tap_notify_any(client)) {
|
||||
continue;
|
||||
}
|
||||
if (out->events_count >= sizeof(out->events) / sizeof(out->events[0])) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t kind = 0;
|
||||
uint32_t age_ms = 0;
|
||||
if (!client_registry_take_tap(client->id, &kind, &age_ms)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
alox_TapEvent *event = &out->events[out->events_count++];
|
||||
event->client_id = client->id;
|
||||
event->valid = true;
|
||||
event->kind = tap_kind_from_registry(kind);
|
||||
event->age_ms = age_ms;
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_tap_snapshot(const uint8_t *data, size_t len) {
|
||||
uint32_t filter_client_id = 0;
|
||||
|
||||
if (len > 0) {
|
||||
alox_UartMessage req;
|
||||
if (uart_cmd_decode(data, len, &req) == ESP_OK) {
|
||||
alox_TapSnapshotRequest *snap_req = UART_CMD_REQ(
|
||||
&req, alox_UartMessage_tap_snapshot_request_tag, tap_snapshot_request);
|
||||
if (snap_req != NULL) {
|
||||
filter_client_id = snap_req->client_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
alox_UartMessage response;
|
||||
uart_cmd_init_response(&response, alox_MessageType_TAP_SNAPSHOT,
|
||||
alox_UartMessage_tap_snapshot_response_tag);
|
||||
fill_tap_snapshot(&response.payload.tap_snapshot_response, filter_client_id);
|
||||
|
||||
uart_cmd_send(&response, TAG);
|
||||
}
|
||||
|
||||
void cmd_tap_snapshot_register(void) {
|
||||
uart_cmd_register(alox_MessageType_TAP_SNAPSHOT, handle_tap_snapshot);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef CMD_TAP_SNAPSHOT_H
|
||||
#define CMD_TAP_SNAPSHOT_H
|
||||
|
||||
void cmd_tap_snapshot_register(void);
|
||||
|
||||
#endif
|
||||
@@ -43,6 +43,9 @@ static uint8_t s_wifi_channel;
|
||||
static uint8_t s_own_mac[ESP_NOW_ETH_ALEN];
|
||||
static bool s_slave_joined;
|
||||
static bool s_accel_stream_enabled;
|
||||
static bool s_tap_notify_single;
|
||||
static bool s_tap_notify_double;
|
||||
static bool s_tap_notify_triple;
|
||||
static uint8_t s_master_mac[ESP_NOW_ETH_ALEN];
|
||||
static uint32_t s_last_discover_ms;
|
||||
|
||||
@@ -138,6 +141,28 @@ static esp_err_t send_accel_sample(const uint8_t *dest_mac, uint32_t slave_id,
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_tap_event(const uint8_t *dest_mac, uint32_t slave_id,
|
||||
uint32_t kind) {
|
||||
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
|
||||
msg.type = alox_EspNowMessageType_ESPNOW_TAP_EVENT;
|
||||
msg.which_payload = alox_EspNowMessage_tap_event_tag;
|
||||
msg.payload.tap_event.slave_id = slave_id;
|
||||
msg.payload.tap_event.kind = kind;
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_tap_notify(const uint8_t *dest_mac, uint32_t client_id,
|
||||
bool single, bool double_tap, bool triple) {
|
||||
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
|
||||
msg.type = alox_EspNowMessageType_ESPNOW_SET_TAP_NOTIFY;
|
||||
msg.which_payload = alox_EspNowMessage_tap_notify_tag;
|
||||
msg.payload.tap_notify.client_id = client_id;
|
||||
msg.payload.tap_notify.single = single;
|
||||
msg.payload.tap_notify.double_tap = double_tap;
|
||||
msg.payload.tap_notify.triple = triple;
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_message_ex(const uint8_t *dest_mac,
|
||||
const alox_EspNowMessage *msg, bool wait_done) {
|
||||
uint8_t buf[ESPNOW_PB_MAX_SIZE];
|
||||
@@ -455,6 +480,29 @@ esp_err_t esp_now_comm_send_accel_stream(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
return err;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (mac == NULL || !s_config.master) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
char mac_str[18];
|
||||
mac_to_str(mac, mac_str, sizeof(mac_str));
|
||||
esp_err_t err =
|
||||
send_tap_notify(mac, client_id, single, double_tap, triple);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG,
|
||||
"unicast SET_TAP_NOTIFY to %s: single=%d double=%d triple=%d "
|
||||
"client_id=%lu",
|
||||
mac_str, single, double_tap, triple, (unsigned long)client_id);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "unicast SET_TAP_NOTIFY to %s failed: %s", mac_str,
|
||||
esp_err_to_name(err));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_now_comm_send_accel_deadzone(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id, uint32_t deadzone) {
|
||||
if (mac == NULL || !s_config.master) {
|
||||
@@ -705,6 +753,30 @@ static void handle_slave_accel_stream(const uint8_t *master_mac,
|
||||
cfg->enable ? "on" : "off", mac_str, (unsigned long)my_id);
|
||||
}
|
||||
|
||||
static void handle_slave_tap_notify(const uint8_t *master_mac,
|
||||
const alox_EspNowTapNotify *cfg) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
|
||||
if (cfg->client_id != 0 && cfg->client_id != my_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_slave_joined && !mac_equal(master_mac, s_master_mac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_tap_notify_single = cfg->single;
|
||||
s_tap_notify_double = cfg->double_tap;
|
||||
s_tap_notify_triple = cfg->triple;
|
||||
|
||||
char mac_str[18];
|
||||
mac_to_str(master_mac, mac_str, sizeof(mac_str));
|
||||
ESP_LOGI(TAG,
|
||||
"tap notify single=%d double=%d triple=%d from master %s (id=%lu)",
|
||||
cfg->single, cfg->double_tap, cfg->triple, mac_str,
|
||||
(unsigned long)my_id);
|
||||
}
|
||||
|
||||
static void handle_slave_accel_deadzone(const uint8_t *master_mac,
|
||||
const alox_EspNowAccelDeadzone *cfg) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
@@ -749,6 +821,24 @@ static void handle_master_accel_sample(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_master_tap_event(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
const alox_EspNowTapEvent *event) {
|
||||
if (event == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
esp_err_t err =
|
||||
client_registry_update_tap(mac, event->slave_id, event->kind);
|
||||
if (err == ESP_ERR_NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "tap event id=%lu kind=%lu rejected from %02x:…:%02x",
|
||||
(unsigned long)event->slave_id, (unsigned long)event->kind, mac[0],
|
||||
mac[5]);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_client_presence(const alox_EspNowSlavePresence *presence,
|
||||
const uint8_t mac[CLIENT_MAC_LEN]) {
|
||||
if (presence->network != s_config.network) {
|
||||
@@ -855,6 +945,34 @@ static void slave_accel_stream_task(void *param) {
|
||||
}
|
||||
}
|
||||
|
||||
static void on_bma456_tap(bma456_tap_kind_t kind, void *ctx) {
|
||||
(void)ctx;
|
||||
|
||||
if (!s_slave_joined) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool enabled = false;
|
||||
switch (kind) {
|
||||
case BMA456_TAP_SINGLE:
|
||||
enabled = s_tap_notify_single;
|
||||
break;
|
||||
case BMA456_TAP_DOUBLE:
|
||||
enabled = s_tap_notify_double;
|
||||
break;
|
||||
case BMA456_TAP_TRIPLE:
|
||||
enabled = s_tap_notify_triple;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
(void)send_tap_event(s_master_mac, s_own_mac[5], (uint32_t)kind);
|
||||
}
|
||||
|
||||
static void slave_heartbeat_task(void *param) {
|
||||
(void)param;
|
||||
uint32_t last_battery_ms = 0;
|
||||
@@ -942,6 +1060,12 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
|
||||
}
|
||||
handle_slave_accel_stream(info->src_addr, &msg.payload.accel_stream);
|
||||
break;
|
||||
case alox_EspNowMessage_tap_notify_tag:
|
||||
if (!s_slave_joined || !mac_equal(info->src_addr, s_master_mac)) {
|
||||
break;
|
||||
}
|
||||
handle_slave_tap_notify(info->src_addr, &msg.payload.tap_notify);
|
||||
break;
|
||||
case alox_EspNowMessage_battery_query_tag:
|
||||
if (!s_slave_joined || !mac_equal(info->src_addr, s_master_mac)) {
|
||||
break;
|
||||
@@ -1007,6 +1131,12 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.which_payload == alox_EspNowMessage_tap_event_tag) {
|
||||
ensure_peer(info->src_addr);
|
||||
handle_master_tap_event(info->src_addr, &msg.payload.tap_event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.which_payload == alox_EspNowMessage_battery_report_tag) {
|
||||
ensure_peer(info->src_addr);
|
||||
handle_master_battery_report(info->src_addr, &msg.payload.battery_report);
|
||||
@@ -1133,6 +1263,7 @@ esp_err_t esp_now_comm_init(const app_config_t *config) {
|
||||
ESP_LOGE(TAG, "failed to create accel stream task");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
bma456_set_tap_handler(on_bma456_tap, NULL);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
@@ -13,6 +13,11 @@ esp_err_t esp_now_comm_init(const app_config_t *config);
|
||||
esp_err_t esp_now_comm_send_accel_stream(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id, bool enable);
|
||||
|
||||
/** 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);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "cmd_accel_deadzone.h"
|
||||
#include "cmd_accel_snapshot.h"
|
||||
#include "cmd_accel_stream.h"
|
||||
#include "cmd_tap_notify.h"
|
||||
#include "cmd_tap_snapshot.h"
|
||||
#include "cmd_espnow_unicast_test.h"
|
||||
#include "cmd_espnow_find_me.h"
|
||||
#include "cmd_restart.h"
|
||||
@@ -182,6 +184,8 @@ void app_main(void) {
|
||||
cmd_accel_deadzone_register();
|
||||
cmd_accel_snapshot_register();
|
||||
cmd_accel_stream_register();
|
||||
cmd_tap_notify_register();
|
||||
cmd_tap_snapshot_register();
|
||||
cmd_espnow_unicast_test_register();
|
||||
cmd_espnow_find_me_register();
|
||||
cmd_restart_register();
|
||||
|
||||
@@ -33,6 +33,12 @@ PB_BIND(alox_EspNowAccelSample, alox_EspNowAccelSample, AUTO)
|
||||
PB_BIND(alox_EspNowBatteryQuery, alox_EspNowBatteryQuery, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowTapNotify, alox_EspNowTapNotify, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowTapEvent, alox_EspNowTapEvent, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowBatteryReport, alox_EspNowBatteryReport, AUTO)
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ typedef enum _alox_EspNowMessageType {
|
||||
alox_EspNowMessageType_ESPNOW_SET_ACCEL_STREAM = 13,
|
||||
alox_EspNowMessageType_ESPNOW_LED_RING = 14,
|
||||
alox_EspNowMessageType_ESPNOW_BATTERY_QUERY = 15,
|
||||
alox_EspNowMessageType_ESPNOW_BATTERY_REPORT = 16
|
||||
alox_EspNowMessageType_ESPNOW_BATTERY_REPORT = 16,
|
||||
alox_EspNowMessageType_ESPNOW_SET_TAP_NOTIFY = 17,
|
||||
alox_EspNowMessageType_ESPNOW_TAP_EVENT = 18
|
||||
} alox_EspNowMessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@@ -83,6 +85,21 @@ typedef struct _alox_EspNowBatteryQuery {
|
||||
uint32_t client_id;
|
||||
} alox_EspNowBatteryQuery;
|
||||
|
||||
/* * Master → slave: which tap kinds should be reported via ESP-NOW. */
|
||||
typedef struct _alox_EspNowTapNotify {
|
||||
uint32_t client_id;
|
||||
bool single;
|
||||
bool double_tap;
|
||||
bool triple;
|
||||
} alox_EspNowTapNotify;
|
||||
|
||||
/* * Slave → master: tap detected on BMA456 (event, not periodic). */
|
||||
typedef struct _alox_EspNowTapEvent {
|
||||
uint32_t slave_id;
|
||||
/* * 1=single, 2=double, 3=triple */
|
||||
uint32_t kind;
|
||||
} alox_EspNowTapEvent;
|
||||
|
||||
/* * Slave → master: LiPo voltages (periodic ~30 s and on query). */
|
||||
typedef struct _alox_EspNowBatteryReport {
|
||||
uint32_t client_id;
|
||||
@@ -150,6 +167,8 @@ typedef struct _alox_EspNowMessage {
|
||||
alox_EspNowLedRing led_ring;
|
||||
alox_EspNowBatteryQuery battery_query;
|
||||
alox_EspNowBatteryReport battery_report;
|
||||
alox_EspNowTapNotify tap_notify;
|
||||
alox_EspNowTapEvent tap_event;
|
||||
} payload;
|
||||
} alox_EspNowMessage;
|
||||
|
||||
@@ -160,8 +179,10 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_BATTERY_REPORT
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_BATTERY_REPORT+1))
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_TAP_EVENT
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_TAP_EVENT+1))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -191,6 +212,8 @@ extern "C" {
|
||||
#define alox_EspNowAccelStream_init_default {0, 0}
|
||||
#define alox_EspNowAccelSample_init_default {0, 0, 0, 0}
|
||||
#define alox_EspNowBatteryQuery_init_default {0}
|
||||
#define alox_EspNowTapNotify_init_default {0, 0, 0, 0}
|
||||
#define alox_EspNowTapEvent_init_default {0, 0}
|
||||
#define alox_EspNowBatteryReport_init_default {0, 0, 0, 0, 0}
|
||||
#define alox_EspNowLedRing_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_EspNowOtaStart_init_default {0}
|
||||
@@ -207,6 +230,8 @@ extern "C" {
|
||||
#define alox_EspNowAccelStream_init_zero {0, 0}
|
||||
#define alox_EspNowAccelSample_init_zero {0, 0, 0, 0}
|
||||
#define alox_EspNowBatteryQuery_init_zero {0}
|
||||
#define alox_EspNowTapNotify_init_zero {0, 0, 0, 0}
|
||||
#define alox_EspNowTapEvent_init_zero {0, 0}
|
||||
#define alox_EspNowBatteryReport_init_zero {0, 0, 0, 0, 0}
|
||||
#define alox_EspNowLedRing_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_EspNowOtaStart_init_zero {0}
|
||||
@@ -235,6 +260,12 @@ extern "C" {
|
||||
#define alox_EspNowAccelSample_y_tag 3
|
||||
#define alox_EspNowAccelSample_z_tag 4
|
||||
#define alox_EspNowBatteryQuery_client_id_tag 1
|
||||
#define alox_EspNowTapNotify_client_id_tag 1
|
||||
#define alox_EspNowTapNotify_single_tag 2
|
||||
#define alox_EspNowTapNotify_double_tap_tag 3
|
||||
#define alox_EspNowTapNotify_triple_tag 4
|
||||
#define alox_EspNowTapEvent_slave_id_tag 1
|
||||
#define alox_EspNowTapEvent_kind_tag 2
|
||||
#define alox_EspNowBatteryReport_client_id_tag 1
|
||||
#define alox_EspNowBatteryReport_lipo1_valid_tag 2
|
||||
#define alox_EspNowBatteryReport_lipo2_valid_tag 3
|
||||
@@ -273,6 +304,8 @@ extern "C" {
|
||||
#define alox_EspNowMessage_led_ring_tag 15
|
||||
#define alox_EspNowMessage_battery_query_tag 16
|
||||
#define alox_EspNowMessage_battery_report_tag 17
|
||||
#define alox_EspNowMessage_tap_notify_tag 18
|
||||
#define alox_EspNowMessage_tap_event_tag 19
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
|
||||
@@ -330,6 +363,20 @@ X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowBatteryQuery_CALLBACK NULL
|
||||
#define alox_EspNowBatteryQuery_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowTapNotify_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, single, 2) \
|
||||
X(a, STATIC, SINGULAR, BOOL, double_tap, 3) \
|
||||
X(a, STATIC, SINGULAR, BOOL, triple, 4)
|
||||
#define alox_EspNowTapNotify_CALLBACK NULL
|
||||
#define alox_EspNowTapNotify_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowTapEvent_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, slave_id, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, kind, 2)
|
||||
#define alox_EspNowTapEvent_CALLBACK NULL
|
||||
#define alox_EspNowTapEvent_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowBatteryReport_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, lipo1_valid, 2) \
|
||||
@@ -393,7 +440,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,accel_sample,payload.accel_sample),
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream,payload.accel_stream), 14) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring,payload.led_ring), 15) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_query,payload.battery_query), 16) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_report,payload.battery_report), 17)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_report,payload.battery_report), 17) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_notify,payload.tap_notify), 18) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_event,payload.tap_event), 19)
|
||||
#define alox_EspNowMessage_CALLBACK NULL
|
||||
#define alox_EspNowMessage_DEFAULT NULL
|
||||
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
|
||||
@@ -412,6 +461,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,battery_report,payload.battery_repor
|
||||
#define alox_EspNowMessage_payload_led_ring_MSGTYPE alox_EspNowLedRing
|
||||
#define alox_EspNowMessage_payload_battery_query_MSGTYPE alox_EspNowBatteryQuery
|
||||
#define alox_EspNowMessage_payload_battery_report_MSGTYPE alox_EspNowBatteryReport
|
||||
#define alox_EspNowMessage_payload_tap_notify_MSGTYPE alox_EspNowTapNotify
|
||||
#define alox_EspNowMessage_payload_tap_event_MSGTYPE alox_EspNowTapEvent
|
||||
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMe_msg;
|
||||
@@ -422,6 +473,8 @@ extern const pb_msgdesc_t alox_EspNowAccelDeadzone_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowAccelStream_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowAccelSample_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowBatteryQuery_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowTapNotify_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowTapEvent_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowBatteryReport_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowLedRing_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowOtaStart_msg;
|
||||
@@ -440,6 +493,8 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
#define alox_EspNowAccelStream_fields &alox_EspNowAccelStream_msg
|
||||
#define alox_EspNowAccelSample_fields &alox_EspNowAccelSample_msg
|
||||
#define alox_EspNowBatteryQuery_fields &alox_EspNowBatteryQuery_msg
|
||||
#define alox_EspNowTapNotify_fields &alox_EspNowTapNotify_msg
|
||||
#define alox_EspNowTapEvent_fields &alox_EspNowTapEvent_msg
|
||||
#define alox_EspNowBatteryReport_fields &alox_EspNowBatteryReport_msg
|
||||
#define alox_EspNowLedRing_fields &alox_EspNowLedRing_msg
|
||||
#define alox_EspNowOtaStart_fields &alox_EspNowOtaStart_msg
|
||||
@@ -465,6 +520,8 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
#define alox_EspNowOtaStart_size 6
|
||||
#define alox_EspNowOtaStatus_size 18
|
||||
#define alox_EspNowRestart_size 6
|
||||
#define alox_EspNowTapEvent_size 12
|
||||
#define alox_EspNowTapNotify_size 12
|
||||
#define alox_EspNowUnicastTest_size 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -22,6 +22,8 @@ enum EspNowMessageType {
|
||||
ESPNOW_LED_RING = 14;
|
||||
ESPNOW_BATTERY_QUERY = 15;
|
||||
ESPNOW_BATTERY_REPORT = 16;
|
||||
ESPNOW_SET_TAP_NOTIFY = 17;
|
||||
ESPNOW_TAP_EVENT = 18;
|
||||
}
|
||||
|
||||
message EspNowUnicastTest {
|
||||
@@ -76,6 +78,21 @@ message EspNowBatteryQuery {
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
/** Master → slave: which tap kinds should be reported via ESP-NOW. */
|
||||
message EspNowTapNotify {
|
||||
uint32 client_id = 1;
|
||||
bool single = 2;
|
||||
bool double_tap = 3;
|
||||
bool triple = 4;
|
||||
}
|
||||
|
||||
/** Slave → master: tap detected on BMA456 (event, not periodic). */
|
||||
message EspNowTapEvent {
|
||||
uint32 slave_id = 1;
|
||||
/** 1=single, 2=double, 3=triple */
|
||||
uint32 kind = 2;
|
||||
}
|
||||
|
||||
/** Slave → master: LiPo voltages (periodic ~30 s and on query). */
|
||||
message EspNowBatteryReport {
|
||||
uint32 client_id = 1;
|
||||
@@ -139,5 +156,7 @@ message EspNowMessage {
|
||||
EspNowLedRing led_ring = 15;
|
||||
EspNowBatteryQuery battery_query = 16;
|
||||
EspNowBatteryReport battery_report = 17;
|
||||
EspNowTapNotify tap_notify = 18;
|
||||
EspNowTapEvent tap_event = 19;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,21 @@ PB_BIND(alox_AccelSample, alox_AccelSample, AUTO)
|
||||
PB_BIND(alox_AccelSnapshotResponse, alox_AccelSnapshotResponse, 2)
|
||||
|
||||
|
||||
PB_BIND(alox_TapNotifyRequest, alox_TapNotifyRequest, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_TapNotifyResponse, alox_TapNotifyResponse, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_TapSnapshotRequest, alox_TapSnapshotRequest, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_TapEvent, alox_TapEvent, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_TapSnapshotResponse, alox_TapSnapshotResponse, 2)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowUnicastTestRequest, alox_EspNowUnicastTestRequest, AUTO)
|
||||
|
||||
|
||||
@@ -111,3 +126,5 @@ PB_BIND(alox_OtaSlaveProgressResponse, alox_OtaSlaveProgressResponse, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -30,9 +30,18 @@ typedef enum _alox_MessageType {
|
||||
alox_MessageType_RESTART = 23,
|
||||
alox_MessageType_ACCEL_SNAPSHOT = 24,
|
||||
alox_MessageType_ACCEL_STREAM = 25,
|
||||
alox_MessageType_BATTERY_STATUS = 26
|
||||
alox_MessageType_BATTERY_STATUS = 26,
|
||||
alox_MessageType_TAP_NOTIFY = 27,
|
||||
alox_MessageType_TAP_SNAPSHOT = 28
|
||||
} alox_MessageType;
|
||||
|
||||
typedef enum _alox_TapKind {
|
||||
alox_TapKind_TAP_NONE = 0,
|
||||
alox_TapKind_TAP_SINGLE = 1,
|
||||
alox_TapKind_TAP_DOUBLE = 2,
|
||||
alox_TapKind_TAP_TRIPLE = 3
|
||||
} alox_TapKind;
|
||||
|
||||
/* Struct definitions */
|
||||
typedef struct _alox_Ack {
|
||||
char dummy_field;
|
||||
@@ -59,6 +68,10 @@ typedef struct _alox_ClientInfo {
|
||||
uint32_t version;
|
||||
/* * Master: ESP-NOW accel stream enabled for this slave. */
|
||||
bool accel_stream_enabled;
|
||||
/* * Master: ESP-NOW tap notify flags for this slave. */
|
||||
bool tap_notify_single;
|
||||
bool tap_notify_double;
|
||||
bool tap_notify_triple;
|
||||
} alox_ClientInfo;
|
||||
|
||||
typedef struct _alox_ClientInfoResponse {
|
||||
@@ -160,6 +173,42 @@ typedef struct _alox_AccelSnapshotResponse {
|
||||
alox_AccelSample samples[16];
|
||||
} alox_AccelSnapshotResponse;
|
||||
|
||||
/* * Host → master: enable/disable tap ESP-NOW notify per slave (single/double/triple). */
|
||||
typedef struct _alox_TapNotifyRequest {
|
||||
bool write;
|
||||
uint32_t client_id;
|
||||
bool all_clients;
|
||||
bool single;
|
||||
bool double_tap;
|
||||
bool triple;
|
||||
} alox_TapNotifyRequest;
|
||||
|
||||
typedef struct _alox_TapNotifyResponse {
|
||||
uint32_t client_id;
|
||||
bool success;
|
||||
uint32_t slaves_updated;
|
||||
bool single;
|
||||
bool double_tap;
|
||||
bool triple;
|
||||
} alox_TapNotifyResponse;
|
||||
|
||||
/* * Host → master: read cached tap events (discarded after reply or when age > 16 ms). */
|
||||
typedef struct _alox_TapSnapshotRequest {
|
||||
uint32_t client_id;
|
||||
} alox_TapSnapshotRequest;
|
||||
|
||||
typedef struct _alox_TapEvent {
|
||||
uint32_t client_id;
|
||||
bool valid;
|
||||
alox_TapKind kind;
|
||||
uint32_t age_ms;
|
||||
} alox_TapEvent;
|
||||
|
||||
typedef struct _alox_TapSnapshotResponse {
|
||||
pb_size_t events_count;
|
||||
alox_TapEvent events[16];
|
||||
} alox_TapSnapshotResponse;
|
||||
|
||||
typedef struct _alox_EspNowUnicastTestRequest {
|
||||
uint32_t client_id;
|
||||
uint32_t seq;
|
||||
@@ -304,6 +353,10 @@ typedef struct _alox_UartMessage {
|
||||
alox_AccelStreamResponse accel_stream_response;
|
||||
alox_BatteryStatusRequest battery_status_request;
|
||||
alox_BatteryStatusResponse battery_status_response;
|
||||
alox_TapNotifyRequest tap_notify_request;
|
||||
alox_TapNotifyResponse tap_notify_response;
|
||||
alox_TapSnapshotRequest tap_snapshot_request;
|
||||
alox_TapSnapshotResponse tap_snapshot_response;
|
||||
} payload;
|
||||
} alox_UartMessage;
|
||||
|
||||
@@ -314,8 +367,12 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_MessageType_MIN alox_MessageType_UNKNOWN
|
||||
#define _alox_MessageType_MAX alox_MessageType_BATTERY_STATUS
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_BATTERY_STATUS+1))
|
||||
#define _alox_MessageType_MAX alox_MessageType_TAP_SNAPSHOT
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_TAP_SNAPSHOT+1))
|
||||
|
||||
#define _alox_TapKind_MIN alox_TapKind_TAP_NONE
|
||||
#define _alox_TapKind_MAX alox_TapKind_TAP_TRIPLE
|
||||
#define _alox_TapKind_ARRAYSIZE ((alox_TapKind)(alox_TapKind_TAP_TRIPLE+1))
|
||||
|
||||
#define alox_UartMessage_type_ENUMTYPE alox_MessageType
|
||||
|
||||
@@ -338,6 +395,12 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define alox_TapEvent_kind_ENUMTYPE alox_TapKind
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -358,7 +421,7 @@ extern "C" {
|
||||
#define alox_Ack_init_default {0}
|
||||
#define alox_EchoPayload_init_default {{{NULL}, NULL}}
|
||||
#define alox_VersionResponse_init_default {0, {{NULL}, NULL}, {{NULL}, NULL}}
|
||||
#define alox_ClientInfo_init_default {0, 0, 0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_ClientInfo_init_default {0, 0, 0, {{NULL}, NULL}, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_ClientInfoResponse_init_default {{{NULL}, NULL}}
|
||||
#define alox_ClientInput_init_default {0, 0, 0, 0}
|
||||
#define alox_ClientInputResponse_init_default {{{NULL}, NULL}}
|
||||
@@ -373,6 +436,11 @@ extern "C" {
|
||||
#define alox_AccelSnapshotRequest_init_default {0}
|
||||
#define alox_AccelSample_init_default {0, 0, 0, 0, 0, 0}
|
||||
#define alox_AccelSnapshotResponse_init_default {0, {alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default, alox_AccelSample_init_default}}
|
||||
#define alox_TapNotifyRequest_init_default {0, 0, 0, 0, 0, 0}
|
||||
#define alox_TapNotifyResponse_init_default {0, 0, 0, 0, 0, 0}
|
||||
#define alox_TapSnapshotRequest_init_default {0}
|
||||
#define alox_TapEvent_init_default {0, 0, _alox_TapKind_MIN, 0}
|
||||
#define alox_TapSnapshotResponse_init_default {0, {alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default, alox_TapEvent_init_default}}
|
||||
#define alox_EspNowUnicastTestRequest_init_default {0, 0}
|
||||
#define alox_EspNowUnicastTestResponse_init_default {0, 0}
|
||||
#define alox_LedRingProgressRequest_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
@@ -392,7 +460,7 @@ extern "C" {
|
||||
#define alox_Ack_init_zero {0}
|
||||
#define alox_EchoPayload_init_zero {{{NULL}, NULL}}
|
||||
#define alox_VersionResponse_init_zero {0, {{NULL}, NULL}, {{NULL}, NULL}}
|
||||
#define alox_ClientInfo_init_zero {0, 0, 0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_ClientInfo_init_zero {0, 0, 0, {{NULL}, NULL}, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_ClientInfoResponse_init_zero {{{NULL}, NULL}}
|
||||
#define alox_ClientInput_init_zero {0, 0, 0, 0}
|
||||
#define alox_ClientInputResponse_init_zero {{{NULL}, NULL}}
|
||||
@@ -407,6 +475,11 @@ extern "C" {
|
||||
#define alox_AccelSnapshotRequest_init_zero {0}
|
||||
#define alox_AccelSample_init_zero {0, 0, 0, 0, 0, 0}
|
||||
#define alox_AccelSnapshotResponse_init_zero {0, {alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero, alox_AccelSample_init_zero}}
|
||||
#define alox_TapNotifyRequest_init_zero {0, 0, 0, 0, 0, 0}
|
||||
#define alox_TapNotifyResponse_init_zero {0, 0, 0, 0, 0, 0}
|
||||
#define alox_TapSnapshotRequest_init_zero {0}
|
||||
#define alox_TapEvent_init_zero {0, 0, _alox_TapKind_MIN, 0}
|
||||
#define alox_TapSnapshotResponse_init_zero {0, {alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero, alox_TapEvent_init_zero}}
|
||||
#define alox_EspNowUnicastTestRequest_init_zero {0, 0}
|
||||
#define alox_EspNowUnicastTestResponse_init_zero {0, 0}
|
||||
#define alox_LedRingProgressRequest_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
@@ -436,6 +509,9 @@ extern "C" {
|
||||
#define alox_ClientInfo_last_success_ping_tag 6
|
||||
#define alox_ClientInfo_version_tag 7
|
||||
#define alox_ClientInfo_accel_stream_enabled_tag 8
|
||||
#define alox_ClientInfo_tap_notify_single_tag 9
|
||||
#define alox_ClientInfo_tap_notify_double_tag 10
|
||||
#define alox_ClientInfo_tap_notify_triple_tag 11
|
||||
#define alox_ClientInfoResponse_clients_tag 1
|
||||
#define alox_ClientInput_id_tag 1
|
||||
#define alox_ClientInput_lage_x_tag 2
|
||||
@@ -476,6 +552,24 @@ extern "C" {
|
||||
#define alox_AccelSample_z_tag 5
|
||||
#define alox_AccelSample_age_ms_tag 6
|
||||
#define alox_AccelSnapshotResponse_samples_tag 1
|
||||
#define alox_TapNotifyRequest_write_tag 1
|
||||
#define alox_TapNotifyRequest_client_id_tag 2
|
||||
#define alox_TapNotifyRequest_all_clients_tag 3
|
||||
#define alox_TapNotifyRequest_single_tag 4
|
||||
#define alox_TapNotifyRequest_double_tap_tag 5
|
||||
#define alox_TapNotifyRequest_triple_tag 6
|
||||
#define alox_TapNotifyResponse_client_id_tag 1
|
||||
#define alox_TapNotifyResponse_success_tag 2
|
||||
#define alox_TapNotifyResponse_slaves_updated_tag 3
|
||||
#define alox_TapNotifyResponse_single_tag 4
|
||||
#define alox_TapNotifyResponse_double_tap_tag 5
|
||||
#define alox_TapNotifyResponse_triple_tag 6
|
||||
#define alox_TapSnapshotRequest_client_id_tag 1
|
||||
#define alox_TapEvent_client_id_tag 1
|
||||
#define alox_TapEvent_valid_tag 2
|
||||
#define alox_TapEvent_kind_tag 3
|
||||
#define alox_TapEvent_age_ms_tag 4
|
||||
#define alox_TapSnapshotResponse_events_tag 1
|
||||
#define alox_EspNowUnicastTestRequest_client_id_tag 1
|
||||
#define alox_EspNowUnicastTestRequest_seq_tag 2
|
||||
#define alox_EspNowUnicastTestResponse_success_tag 1
|
||||
@@ -550,6 +644,10 @@ extern "C" {
|
||||
#define alox_UartMessage_accel_stream_response_tag 26
|
||||
#define alox_UartMessage_battery_status_request_tag 27
|
||||
#define alox_UartMessage_battery_status_response_tag 28
|
||||
#define alox_UartMessage_tap_notify_request_tag 29
|
||||
#define alox_UartMessage_tap_notify_response_tag 30
|
||||
#define alox_UartMessage_tap_snapshot_request_tag 31
|
||||
#define alox_UartMessage_tap_snapshot_response_tag 32
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_UartMessage_FIELDLIST(X, a) \
|
||||
@@ -580,7 +678,11 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,accel_snapshot_response,payload.acce
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream_request,payload.accel_stream_request), 25) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream_response,payload.accel_stream_response), 26) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_status_request,payload.battery_status_request), 27) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_status_response,payload.battery_status_response), 28)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_status_response,payload.battery_status_response), 28) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_notify_request,payload.tap_notify_request), 29) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_notify_response,payload.tap_notify_response), 30) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_snapshot_request,payload.tap_snapshot_request), 31) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_snapshot_response,payload.tap_snapshot_response), 32)
|
||||
#define alox_UartMessage_CALLBACK NULL
|
||||
#define alox_UartMessage_DEFAULT NULL
|
||||
#define alox_UartMessage_payload_ack_payload_MSGTYPE alox_Ack
|
||||
@@ -610,6 +712,10 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,battery_status_response,payload.batt
|
||||
#define alox_UartMessage_payload_accel_stream_response_MSGTYPE alox_AccelStreamResponse
|
||||
#define alox_UartMessage_payload_battery_status_request_MSGTYPE alox_BatteryStatusRequest
|
||||
#define alox_UartMessage_payload_battery_status_response_MSGTYPE alox_BatteryStatusResponse
|
||||
#define alox_UartMessage_payload_tap_notify_request_MSGTYPE alox_TapNotifyRequest
|
||||
#define alox_UartMessage_payload_tap_notify_response_MSGTYPE alox_TapNotifyResponse
|
||||
#define alox_UartMessage_payload_tap_snapshot_request_MSGTYPE alox_TapSnapshotRequest
|
||||
#define alox_UartMessage_payload_tap_snapshot_response_MSGTYPE alox_TapSnapshotResponse
|
||||
|
||||
#define alox_Ack_FIELDLIST(X, a) \
|
||||
|
||||
@@ -636,7 +742,10 @@ X(a, CALLBACK, SINGULAR, BYTES, mac, 4) \
|
||||
X(a, STATIC, SINGULAR, UINT32, last_ping, 5) \
|
||||
X(a, STATIC, SINGULAR, UINT32, last_success_ping, 6) \
|
||||
X(a, STATIC, SINGULAR, UINT32, version, 7) \
|
||||
X(a, STATIC, SINGULAR, BOOL, accel_stream_enabled, 8)
|
||||
X(a, STATIC, SINGULAR, BOOL, accel_stream_enabled, 8) \
|
||||
X(a, STATIC, SINGULAR, BOOL, tap_notify_single, 9) \
|
||||
X(a, STATIC, SINGULAR, BOOL, tap_notify_double, 10) \
|
||||
X(a, STATIC, SINGULAR, BOOL, tap_notify_triple, 11)
|
||||
#define alox_ClientInfo_CALLBACK pb_default_field_callback
|
||||
#define alox_ClientInfo_DEFAULT NULL
|
||||
|
||||
@@ -742,6 +851,45 @@ X(a, STATIC, REPEATED, MESSAGE, samples, 1)
|
||||
#define alox_AccelSnapshotResponse_DEFAULT NULL
|
||||
#define alox_AccelSnapshotResponse_samples_MSGTYPE alox_AccelSample
|
||||
|
||||
#define alox_TapNotifyRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, BOOL, write, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 2) \
|
||||
X(a, STATIC, SINGULAR, BOOL, all_clients, 3) \
|
||||
X(a, STATIC, SINGULAR, BOOL, single, 4) \
|
||||
X(a, STATIC, SINGULAR, BOOL, double_tap, 5) \
|
||||
X(a, STATIC, SINGULAR, BOOL, triple, 6)
|
||||
#define alox_TapNotifyRequest_CALLBACK NULL
|
||||
#define alox_TapNotifyRequest_DEFAULT NULL
|
||||
|
||||
#define alox_TapNotifyResponse_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, success, 2) \
|
||||
X(a, STATIC, SINGULAR, UINT32, slaves_updated, 3) \
|
||||
X(a, STATIC, SINGULAR, BOOL, single, 4) \
|
||||
X(a, STATIC, SINGULAR, BOOL, double_tap, 5) \
|
||||
X(a, STATIC, SINGULAR, BOOL, triple, 6)
|
||||
#define alox_TapNotifyResponse_CALLBACK NULL
|
||||
#define alox_TapNotifyResponse_DEFAULT NULL
|
||||
|
||||
#define alox_TapSnapshotRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_TapSnapshotRequest_CALLBACK NULL
|
||||
#define alox_TapSnapshotRequest_DEFAULT NULL
|
||||
|
||||
#define alox_TapEvent_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, valid, 2) \
|
||||
X(a, STATIC, SINGULAR, UENUM, kind, 3) \
|
||||
X(a, STATIC, SINGULAR, UINT32, age_ms, 4)
|
||||
#define alox_TapEvent_CALLBACK NULL
|
||||
#define alox_TapEvent_DEFAULT NULL
|
||||
|
||||
#define alox_TapSnapshotResponse_FIELDLIST(X, a) \
|
||||
X(a, STATIC, REPEATED, MESSAGE, events, 1)
|
||||
#define alox_TapSnapshotResponse_CALLBACK NULL
|
||||
#define alox_TapSnapshotResponse_DEFAULT NULL
|
||||
#define alox_TapSnapshotResponse_events_MSGTYPE alox_TapEvent
|
||||
|
||||
#define alox_EspNowUnicastTestRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, seq, 2)
|
||||
@@ -869,6 +1017,11 @@ extern const pb_msgdesc_t alox_BatteryStatusResponse_msg;
|
||||
extern const pb_msgdesc_t alox_AccelSnapshotRequest_msg;
|
||||
extern const pb_msgdesc_t alox_AccelSample_msg;
|
||||
extern const pb_msgdesc_t alox_AccelSnapshotResponse_msg;
|
||||
extern const pb_msgdesc_t alox_TapNotifyRequest_msg;
|
||||
extern const pb_msgdesc_t alox_TapNotifyResponse_msg;
|
||||
extern const pb_msgdesc_t alox_TapSnapshotRequest_msg;
|
||||
extern const pb_msgdesc_t alox_TapEvent_msg;
|
||||
extern const pb_msgdesc_t alox_TapSnapshotResponse_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTestRequest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTestResponse_msg;
|
||||
extern const pb_msgdesc_t alox_LedRingProgressRequest_msg;
|
||||
@@ -905,6 +1058,11 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_AccelSnapshotRequest_fields &alox_AccelSnapshotRequest_msg
|
||||
#define alox_AccelSample_fields &alox_AccelSample_msg
|
||||
#define alox_AccelSnapshotResponse_fields &alox_AccelSnapshotResponse_msg
|
||||
#define alox_TapNotifyRequest_fields &alox_TapNotifyRequest_msg
|
||||
#define alox_TapNotifyResponse_fields &alox_TapNotifyResponse_msg
|
||||
#define alox_TapSnapshotRequest_fields &alox_TapSnapshotRequest_msg
|
||||
#define alox_TapEvent_fields &alox_TapEvent_msg
|
||||
#define alox_TapSnapshotResponse_fields &alox_TapSnapshotResponse_msg
|
||||
#define alox_EspNowUnicastTestRequest_fields &alox_EspNowUnicastTestRequest_msg
|
||||
#define alox_EspNowUnicastTestResponse_fields &alox_EspNowUnicastTestResponse_msg
|
||||
#define alox_LedRingProgressRequest_fields &alox_LedRingProgressRequest_msg
|
||||
@@ -957,6 +1115,11 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_OtaStatusPayload_size 24
|
||||
#define alox_RestartRequest_size 6
|
||||
#define alox_RestartResponse_size 8
|
||||
#define alox_TapEvent_size 16
|
||||
#define alox_TapNotifyRequest_size 16
|
||||
#define alox_TapNotifyResponse_size 20
|
||||
#define alox_TapSnapshotRequest_size 6
|
||||
#define alox_TapSnapshotResponse_size 288
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
@@ -25,6 +25,8 @@ enum MessageType {
|
||||
ACCEL_SNAPSHOT = 24;
|
||||
ACCEL_STREAM = 25;
|
||||
BATTERY_STATUS = 26;
|
||||
TAP_NOTIFY = 27;
|
||||
TAP_SNAPSHOT = 28;
|
||||
}
|
||||
|
||||
message UartMessage {
|
||||
@@ -57,6 +59,10 @@ message UartMessage {
|
||||
AccelStreamResponse accel_stream_response = 26;
|
||||
BatteryStatusRequest battery_status_request = 27;
|
||||
BatteryStatusResponse battery_status_response = 28;
|
||||
TapNotifyRequest tap_notify_request = 29;
|
||||
TapNotifyResponse tap_notify_response = 30;
|
||||
TapSnapshotRequest tap_snapshot_request = 31;
|
||||
TapSnapshotResponse tap_snapshot_response = 32;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +89,10 @@ message ClientInfo {
|
||||
uint32 version = 7;
|
||||
/** Master: ESP-NOW accel stream enabled for this slave. */
|
||||
bool accel_stream_enabled = 8;
|
||||
/** Master: ESP-NOW tap notify flags for this slave. */
|
||||
bool tap_notify_single = 9;
|
||||
bool tap_notify_double = 10;
|
||||
bool tap_notify_triple = 11;
|
||||
}
|
||||
|
||||
message ClientInfoResponse {
|
||||
@@ -180,6 +190,48 @@ message AccelSnapshotResponse {
|
||||
repeated AccelSample samples = 1 [(nanopb).max_count = 16];
|
||||
}
|
||||
|
||||
/** Host → master: enable/disable tap ESP-NOW notify per slave (single/double/triple). */
|
||||
message TapNotifyRequest {
|
||||
bool write = 1;
|
||||
uint32 client_id = 2;
|
||||
bool all_clients = 3;
|
||||
bool single = 4;
|
||||
bool double_tap = 5;
|
||||
bool triple = 6;
|
||||
}
|
||||
|
||||
message TapNotifyResponse {
|
||||
uint32 client_id = 1;
|
||||
bool success = 2;
|
||||
uint32 slaves_updated = 3;
|
||||
bool single = 4;
|
||||
bool double_tap = 5;
|
||||
bool triple = 6;
|
||||
}
|
||||
|
||||
enum TapKind {
|
||||
TAP_NONE = 0;
|
||||
TAP_SINGLE = 1;
|
||||
TAP_DOUBLE = 2;
|
||||
TAP_TRIPLE = 3;
|
||||
}
|
||||
|
||||
/** Host → master: read cached tap events (discarded after reply or when age > 16 ms). */
|
||||
message TapSnapshotRequest {
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
message TapEvent {
|
||||
uint32 client_id = 1;
|
||||
bool valid = 2;
|
||||
TapKind kind = 3;
|
||||
uint32 age_ms = 4;
|
||||
}
|
||||
|
||||
message TapSnapshotResponse {
|
||||
repeated TapEvent events = 1 [(nanopb).max_count = 16];
|
||||
}
|
||||
|
||||
message EspNowUnicastTestRequest {
|
||||
uint32 client_id = 1;
|
||||
uint32 seq = 2;
|
||||
|
||||
Reference in New Issue
Block a user