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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user