Add UART ACCEL_READ command for on-demand BMA456 samples.

Expose MessageType 24 with protobuf response (success, x, y, z in raw LSB),
firmware handler with mutex-safe I2C read, goTool `accel` CLI, and docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-28 19:55:02 +02:00
co-authored by Cursor
parent 16c521f71c
commit ba20544762
16 changed files with 479 additions and 99 deletions
+54 -4
View File
@@ -27,7 +27,8 @@ typedef enum _alox_MessageType {
alox_MessageType_OTA_START_ESPNOW = 20,
alox_MessageType_OTA_SLAVE_PROGRESS = 21,
alox_MessageType_FIND_ME = 22,
alox_MessageType_RESTART = 23
alox_MessageType_RESTART = 23,
alox_MessageType_ACCEL_READ = 24
} alox_MessageType;
/* Struct definitions */
@@ -88,6 +89,18 @@ typedef struct _alox_AccelDeadzoneResponse {
uint32_t slaves_updated;
} alox_AccelDeadzoneResponse;
/* Host → device: read current BMA456 accelerometer sample (raw LSB, ±2g range). */
typedef struct _alox_AccelReadRequest {
char dummy_field;
} alox_AccelReadRequest;
typedef struct _alox_AccelReadResponse {
bool success;
int32_t x;
int32_t y;
int32_t z;
} alox_AccelReadResponse;
typedef struct _alox_EspNowUnicastTestRequest {
uint32_t client_id;
uint32_t seq;
@@ -218,6 +231,8 @@ typedef struct _alox_UartMessage {
alox_EspNowFindMeResponse espnow_find_me_response;
alox_RestartRequest restart_request;
alox_RestartResponse restart_response;
alox_AccelReadRequest accel_read_request;
alox_AccelReadResponse accel_read_response;
} payload;
} alox_UartMessage;
@@ -228,8 +243,8 @@ extern "C" {
/* Helper constants for enums */
#define _alox_MessageType_MIN alox_MessageType_UNKNOWN
#define _alox_MessageType_MAX alox_MessageType_RESTART
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_RESTART+1))
#define _alox_MessageType_MAX alox_MessageType_ACCEL_READ
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_ACCEL_READ+1))
#define alox_UartMessage_type_ENUMTYPE alox_MessageType
@@ -255,6 +270,8 @@ extern "C" {
@@ -269,6 +286,8 @@ extern "C" {
#define alox_ClientInputResponse_init_default {{{NULL}, NULL}}
#define alox_AccelDeadzoneRequest_init_default {0, 0, 0, 0}
#define alox_AccelDeadzoneResponse_init_default {0, 0, 0, 0}
#define alox_AccelReadRequest_init_default {0}
#define alox_AccelReadResponse_init_default {0, 0, 0, 0}
#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}
@@ -294,6 +313,8 @@ extern "C" {
#define alox_ClientInputResponse_init_zero {{{NULL}, NULL}}
#define alox_AccelDeadzoneRequest_init_zero {0, 0, 0, 0}
#define alox_AccelDeadzoneResponse_init_zero {0, 0, 0, 0}
#define alox_AccelReadRequest_init_zero {0}
#define alox_AccelReadResponse_init_zero {0, 0, 0, 0}
#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}
@@ -336,6 +357,10 @@ extern "C" {
#define alox_AccelDeadzoneResponse_client_id_tag 2
#define alox_AccelDeadzoneResponse_success_tag 3
#define alox_AccelDeadzoneResponse_slaves_updated_tag 4
#define alox_AccelReadResponse_success_tag 1
#define alox_AccelReadResponse_x_tag 2
#define alox_AccelReadResponse_y_tag 3
#define alox_AccelReadResponse_z_tag 4
#define alox_EspNowUnicastTestRequest_client_id_tag 1
#define alox_EspNowUnicastTestRequest_seq_tag 2
#define alox_EspNowUnicastTestResponse_success_tag 1
@@ -399,6 +424,8 @@ extern "C" {
#define alox_UartMessage_espnow_find_me_response_tag 20
#define alox_UartMessage_restart_request_tag 21
#define alox_UartMessage_restart_response_tag 22
#define alox_UartMessage_accel_read_request_tag 23
#define alox_UartMessage_accel_read_response_tag 24
/* Struct field encoding specification for nanopb */
#define alox_UartMessage_FIELDLIST(X, a) \
@@ -423,7 +450,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring_progress_response,payload.l
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_request,payload.espnow_find_me_request), 19) \
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_response,payload.espnow_find_me_response), 20) \
X(a, STATIC, ONEOF, MESSAGE, (payload,restart_request,payload.restart_request), 21) \
X(a, STATIC, ONEOF, MESSAGE, (payload,restart_response,payload.restart_response), 22)
X(a, STATIC, ONEOF, MESSAGE, (payload,restart_response,payload.restart_response), 22) \
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_read_request,payload.accel_read_request), 23) \
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_read_response,payload.accel_read_response), 24)
#define alox_UartMessage_CALLBACK NULL
#define alox_UartMessage_DEFAULT NULL
#define alox_UartMessage_payload_ack_payload_MSGTYPE alox_Ack
@@ -447,6 +476,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,restart_response,payload.restart_res
#define alox_UartMessage_payload_espnow_find_me_response_MSGTYPE alox_EspNowFindMeResponse
#define alox_UartMessage_payload_restart_request_MSGTYPE alox_RestartRequest
#define alox_UartMessage_payload_restart_response_MSGTYPE alox_RestartResponse
#define alox_UartMessage_payload_accel_read_request_MSGTYPE alox_AccelReadRequest
#define alox_UartMessage_payload_accel_read_response_MSGTYPE alox_AccelReadResponse
#define alox_Ack_FIELDLIST(X, a) \
@@ -512,6 +543,19 @@ X(a, STATIC, SINGULAR, UINT32, slaves_updated, 4)
#define alox_AccelDeadzoneResponse_CALLBACK NULL
#define alox_AccelDeadzoneResponse_DEFAULT NULL
#define alox_AccelReadRequest_FIELDLIST(X, a) \
#define alox_AccelReadRequest_CALLBACK NULL
#define alox_AccelReadRequest_DEFAULT NULL
#define alox_AccelReadResponse_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, BOOL, success, 1) \
X(a, STATIC, SINGULAR, SINT32, x, 2) \
X(a, STATIC, SINGULAR, SINT32, y, 3) \
X(a, STATIC, SINGULAR, SINT32, z, 4)
#define alox_AccelReadResponse_CALLBACK NULL
#define alox_AccelReadResponse_DEFAULT NULL
#define alox_EspNowUnicastTestRequest_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
X(a, STATIC, SINGULAR, UINT32, seq, 2)
@@ -625,6 +669,8 @@ extern const pb_msgdesc_t alox_ClientInput_msg;
extern const pb_msgdesc_t alox_ClientInputResponse_msg;
extern const pb_msgdesc_t alox_AccelDeadzoneRequest_msg;
extern const pb_msgdesc_t alox_AccelDeadzoneResponse_msg;
extern const pb_msgdesc_t alox_AccelReadRequest_msg;
extern const pb_msgdesc_t alox_AccelReadResponse_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;
@@ -652,6 +698,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
#define alox_ClientInputResponse_fields &alox_ClientInputResponse_msg
#define alox_AccelDeadzoneRequest_fields &alox_AccelDeadzoneRequest_msg
#define alox_AccelDeadzoneResponse_fields &alox_AccelDeadzoneResponse_msg
#define alox_AccelReadRequest_fields &alox_AccelReadRequest_msg
#define alox_AccelReadResponse_fields &alox_AccelReadResponse_msg
#define alox_EspNowUnicastTestRequest_fields &alox_EspNowUnicastTestRequest_msg
#define alox_EspNowUnicastTestResponse_fields &alox_EspNowUnicastTestResponse_msg
#define alox_LedRingProgressRequest_fields &alox_LedRingProgressRequest_msg
@@ -678,6 +726,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
#define ALOX_UART_MESSAGES_PB_H_MAX_SIZE alox_OtaSlaveProgressResponse_size
#define alox_AccelDeadzoneRequest_size 16
#define alox_AccelDeadzoneResponse_size 20
#define alox_AccelReadRequest_size 0
#define alox_AccelReadResponse_size 20
#define alox_Ack_size 0
#define alox_ClientInput_size 22
#define alox_EspNowFindMeRequest_size 6