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
+16 -7
View File
@@ -1,4 +1,6 @@
#include "powerpod.h"
#include "cmd_handler.h"
#include "cmd_version.h"
#include "driver/gpio.h"
#include "driver/i2c_master.h"
#include "driver/i2c_types.h"
@@ -7,9 +9,11 @@
#include "esp_log.h"
#include "esp_ota_ops.h"
#include "freertos/FreeRTOS.h"
#include "freertos/idf_additions.h"
#include "led_ring.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "uart.h"
#include <stdint.h>
enum MASTER_STATES {
@@ -47,6 +51,8 @@ static i2c_master_dev_handle_t io_expander;
static struct app_config_t App_Config;
static QueueHandle_t cmd_queue;
uint8_t reverse_high_nibble_lut(uint8_t n) {
static const uint8_t lookup[] = {0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE,
0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF};
@@ -123,15 +129,18 @@ void app_main(void) {
led_ring_init();
cmd_queue = xQueueCreate(10, sizeof(generic_msg_t));
init_cmdHandler(cmd_queue);
init_uart(cmd_queue);
cmd_version_register();
uint8_t current_digit = 10;
while (1) {
led_command_t cmd = {
.mode = LED_CMD_SET_DIGIT,
.value = current_digit,
.r = 5,
.g = 5,
.b = 0
};
led_command_t cmd = {.mode = LED_CMD_SET_DIGIT,
.value = current_digit,
.r = 5,
.g = 5,
.b = 0};
led_ring_send_command(&cmd);
current_digit = (current_digit + 1) % 11;