Stream slave accel via ESP-NOW with master snapshot cache.
Slaves push BMA456 samples at 16ms when enabled; the master caches per client and exposes ACCEL_SNAPSHOT and ACCEL_STREAM over UART. goTool adds dashboard stream controls, HTTP accel-stream routes, and an external WebSocket API with per-connection receive/interval and slave stream commands. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,7 +22,9 @@ typedef enum _alox_EspNowMessageType {
|
||||
alox_EspNowMessageType_ESPNOW_OTA_END = 8,
|
||||
alox_EspNowMessageType_ESPNOW_OTA_STATUS = 9,
|
||||
alox_EspNowMessageType_ESPNOW_FIND_ME = 10,
|
||||
alox_EspNowMessageType_ESPNOW_RESTART = 11
|
||||
alox_EspNowMessageType_ESPNOW_RESTART = 11,
|
||||
alox_EspNowMessageType_ESPNOW_ACCEL_SAMPLE = 12,
|
||||
alox_EspNowMessageType_ESPNOW_SET_ACCEL_STREAM = 13
|
||||
} alox_EspNowMessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@@ -59,6 +61,20 @@ typedef struct _alox_EspNowAccelDeadzone {
|
||||
uint32_t client_id; /* 0 = all slaves; otherwise only matching slave_id applies */
|
||||
} alox_EspNowAccelDeadzone;
|
||||
|
||||
/* * Master → slave: enable/disable periodic accel ESP-NOW stream (~16 ms). */
|
||||
typedef struct _alox_EspNowAccelStream {
|
||||
bool enable;
|
||||
uint32_t client_id;
|
||||
} alox_EspNowAccelStream;
|
||||
|
||||
/* * Slave → master: latest BMA456 sample (sent ~every 16 ms). */
|
||||
typedef struct _alox_EspNowAccelSample {
|
||||
uint32_t slave_id;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
} alox_EspNowAccelSample;
|
||||
|
||||
/* Master → slave: begin OTA (erase inactive slot; slave replies ESPNOW_OTA_STATUS). */
|
||||
typedef struct _alox_EspNowOtaStart {
|
||||
uint32_t total_size;
|
||||
@@ -98,6 +114,8 @@ typedef struct _alox_EspNowMessage {
|
||||
alox_EspNowOtaStatus ota_status;
|
||||
alox_EspNowFindMe find_me;
|
||||
alox_EspNowRestart restart;
|
||||
alox_EspNowAccelSample accel_sample;
|
||||
alox_EspNowAccelStream accel_stream;
|
||||
} payload;
|
||||
} alox_EspNowMessage;
|
||||
|
||||
@@ -108,8 +126,10 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_RESTART
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_RESTART+1))
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_SET_ACCEL_STREAM
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_SET_ACCEL_STREAM+1))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -131,6 +151,8 @@ extern "C" {
|
||||
#define alox_EspNowDiscover_init_default {0}
|
||||
#define alox_EspNowSlavePresence_init_default {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_default {0, 0}
|
||||
#define alox_EspNowAccelStream_init_default {0, 0}
|
||||
#define alox_EspNowAccelSample_init_default {0, 0, 0, 0}
|
||||
#define alox_EspNowOtaStart_init_default {0}
|
||||
#define alox_EspNowOtaPayload_init_default {0, {0, {0}}}
|
||||
#define alox_EspNowOtaEnd_init_default {0}
|
||||
@@ -142,6 +164,8 @@ extern "C" {
|
||||
#define alox_EspNowDiscover_init_zero {0}
|
||||
#define alox_EspNowSlavePresence_init_zero {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_zero {0, 0}
|
||||
#define alox_EspNowAccelStream_init_zero {0, 0}
|
||||
#define alox_EspNowAccelSample_init_zero {0, 0, 0, 0}
|
||||
#define alox_EspNowOtaStart_init_zero {0}
|
||||
#define alox_EspNowOtaPayload_init_zero {0, {0, {0}}}
|
||||
#define alox_EspNowOtaEnd_init_zero {0}
|
||||
@@ -161,6 +185,12 @@ extern "C" {
|
||||
#define alox_EspNowSlavePresence_used_tag 6
|
||||
#define alox_EspNowAccelDeadzone_deadzone_tag 1
|
||||
#define alox_EspNowAccelDeadzone_client_id_tag 2
|
||||
#define alox_EspNowAccelStream_enable_tag 1
|
||||
#define alox_EspNowAccelStream_client_id_tag 2
|
||||
#define alox_EspNowAccelSample_slave_id_tag 1
|
||||
#define alox_EspNowAccelSample_x_tag 2
|
||||
#define alox_EspNowAccelSample_y_tag 3
|
||||
#define alox_EspNowAccelSample_z_tag 4
|
||||
#define alox_EspNowOtaStart_total_size_tag 1
|
||||
#define alox_EspNowOtaPayload_seq_tag 1
|
||||
#define alox_EspNowOtaPayload_data_tag 2
|
||||
@@ -179,6 +209,8 @@ extern "C" {
|
||||
#define alox_EspNowMessage_ota_status_tag 10
|
||||
#define alox_EspNowMessage_find_me_tag 11
|
||||
#define alox_EspNowMessage_restart_tag 12
|
||||
#define alox_EspNowMessage_accel_sample_tag 13
|
||||
#define alox_EspNowMessage_accel_stream_tag 14
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
|
||||
@@ -217,6 +249,20 @@ X(a, STATIC, SINGULAR, UINT32, client_id, 2)
|
||||
#define alox_EspNowAccelDeadzone_CALLBACK NULL
|
||||
#define alox_EspNowAccelDeadzone_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowAccelStream_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, BOOL, enable, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 2)
|
||||
#define alox_EspNowAccelStream_CALLBACK NULL
|
||||
#define alox_EspNowAccelStream_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowAccelSample_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, slave_id, 1) \
|
||||
X(a, STATIC, SINGULAR, SINT32, x, 2) \
|
||||
X(a, STATIC, SINGULAR, SINT32, y, 3) \
|
||||
X(a, STATIC, SINGULAR, SINT32, z, 4)
|
||||
#define alox_EspNowAccelSample_CALLBACK NULL
|
||||
#define alox_EspNowAccelSample_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowOtaStart_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, total_size, 1)
|
||||
#define alox_EspNowOtaStart_CALLBACK NULL
|
||||
@@ -252,7 +298,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,ota_payload,payload.ota_payload),
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_end,payload.ota_end), 9) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_status,payload.ota_status), 10) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,restart,payload.restart), 12)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,restart,payload.restart), 12) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_sample,payload.accel_sample), 13) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_stream,payload.accel_stream), 14)
|
||||
#define alox_EspNowMessage_CALLBACK NULL
|
||||
#define alox_EspNowMessage_DEFAULT NULL
|
||||
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
|
||||
@@ -266,6 +314,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,restart,payload.restart), 12)
|
||||
#define alox_EspNowMessage_payload_ota_status_MSGTYPE alox_EspNowOtaStatus
|
||||
#define alox_EspNowMessage_payload_find_me_MSGTYPE alox_EspNowFindMe
|
||||
#define alox_EspNowMessage_payload_restart_MSGTYPE alox_EspNowRestart
|
||||
#define alox_EspNowMessage_payload_accel_sample_MSGTYPE alox_EspNowAccelSample
|
||||
#define alox_EspNowMessage_payload_accel_stream_MSGTYPE alox_EspNowAccelStream
|
||||
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMe_msg;
|
||||
@@ -273,6 +323,8 @@ extern const pb_msgdesc_t alox_EspNowRestart_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowDiscover_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowSlavePresence_msg;
|
||||
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_EspNowOtaStart_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowOtaPayload_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowOtaEnd_msg;
|
||||
@@ -286,6 +338,8 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
#define alox_EspNowDiscover_fields &alox_EspNowDiscover_msg
|
||||
#define alox_EspNowSlavePresence_fields &alox_EspNowSlavePresence_msg
|
||||
#define alox_EspNowAccelDeadzone_fields &alox_EspNowAccelDeadzone_msg
|
||||
#define alox_EspNowAccelStream_fields &alox_EspNowAccelStream_msg
|
||||
#define alox_EspNowAccelSample_fields &alox_EspNowAccelSample_msg
|
||||
#define alox_EspNowOtaStart_fields &alox_EspNowOtaStart_msg
|
||||
#define alox_EspNowOtaPayload_fields &alox_EspNowOtaPayload_msg
|
||||
#define alox_EspNowOtaEnd_fields &alox_EspNowOtaEnd_msg
|
||||
@@ -297,6 +351,8 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
/* alox_EspNowMessage_size depends on runtime parameters */
|
||||
#define ALOX_ESP_NOW_MESSAGES_PB_H_MAX_SIZE alox_EspNowOtaPayload_size
|
||||
#define alox_EspNowAccelDeadzone_size 12
|
||||
#define alox_EspNowAccelSample_size 24
|
||||
#define alox_EspNowAccelStream_size 8
|
||||
#define alox_EspNowDiscover_size 6
|
||||
#define alox_EspNowFindMe_size 6
|
||||
#define alox_EspNowOtaEnd_size 0
|
||||
|
||||
Reference in New Issue
Block a user