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