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>
35 lines
947 B
C
35 lines
947 B
C
#include "bosch456.h"
|
|
#include "cmd_accel_read.h"
|
|
#include "uart_cmd.h"
|
|
|
|
static const char *TAG = "[ACCEL_READ]";
|
|
|
|
static void reply(bool success, int16_t x, int16_t y, int16_t z) {
|
|
alox_UartMessage response;
|
|
uart_cmd_init_response(&response, alox_MessageType_ACCEL_READ,
|
|
alox_UartMessage_accel_read_response_tag);
|
|
response.payload.accel_read_response.success = success;
|
|
response.payload.accel_read_response.x = x;
|
|
response.payload.accel_read_response.y = y;
|
|
response.payload.accel_read_response.z = z;
|
|
uart_cmd_send(&response, TAG);
|
|
}
|
|
|
|
static void handle_accel_read(const uint8_t *data, size_t len) {
|
|
(void)data;
|
|
(void)len;
|
|
|
|
int16_t x = 0;
|
|
int16_t y = 0;
|
|
int16_t z = 0;
|
|
if (bma456_read_accel(&x, &y, &z) == ESP_OK) {
|
|
reply(true, x, y, z);
|
|
return;
|
|
}
|
|
reply(false, 0, 0, 0);
|
|
}
|
|
|
|
void cmd_accel_read_register(void) {
|
|
uart_cmd_register(alox_MessageType_ACCEL_READ, handle_accel_read);
|
|
}
|