Add command queue dispatcher and VERSION UART handler.

Centralize command dispatch over a FreeRTOS queue so UART and future
ESP-NOW transports can register handlers; implement the protobuf VERSION
command with framed nanopb responses including build git hash.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-18 21:46:51 +02:00
co-authored by Cursor
parent 6b7ccb4256
commit 43a85ce697
12 changed files with 422 additions and 12 deletions
+23
View File
@@ -0,0 +1,23 @@
#include "uart_proto.h"
#include "pb_encode.h"
#include "uart.h"
#include <string.h>
esp_err_t uart_send_uart_message(const alox_UartMessage *msg) {
uint8_t pb_buf[MAX_PAYLOAD_SIZE];
pb_ostream_t stream = pb_ostream_from_buffer(pb_buf, sizeof(pb_buf));
if (!pb_encode(&stream, alox_UartMessage_fields, msg)) {
return ESP_FAIL;
}
uint8_t payload[MAX_PAYLOAD_SIZE];
if (stream.bytes_written + 1 > sizeof(payload)) {
return ESP_ERR_NO_MEM;
}
payload[0] = (uint8_t)msg->type;
memcpy(&payload[1], pb_buf, stream.bytes_written);
return uart_send_framed(payload, stream.bytes_written + 1);
}