Centralize protobuf decode, response init/send, registration, and common nanopb encode callbacks; refactor existing cmd_* modules to use them. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
834 B
C
30 lines
834 B
C
#include "cmd_version.h"
|
|
#include "uart_cmd.h"
|
|
|
|
#ifndef POWERPOD_FW_VERSION
|
|
#define POWERPOD_FW_VERSION 1u
|
|
#endif
|
|
|
|
#ifndef POWERPOD_GIT_HASH
|
|
#define POWERPOD_GIT_HASH "unknown"
|
|
#endif
|
|
|
|
static const char *TAG = "[VERSION]";
|
|
|
|
static void handle_version(const uint8_t *data, size_t len) {
|
|
(void)data;
|
|
(void)len;
|
|
|
|
alox_UartMessage response;
|
|
uart_cmd_init_response(&response, alox_MessageType_VERSION,
|
|
alox_UartMessage_version_response_tag);
|
|
response.payload.version_response.version = POWERPOD_FW_VERSION;
|
|
response.payload.version_response.git_hash.funcs.encode = uart_cmd_encode_string;
|
|
response.payload.version_response.git_hash.arg = (void *)POWERPOD_GIT_HASH;
|
|
uart_cmd_send(&response, TAG);
|
|
}
|
|
|
|
void cmd_version_register(void) {
|
|
uart_cmd_register(alox_MessageType_VERSION, handle_version);
|
|
}
|