Add RESTART command for master and slaves via ESP-NOW.

UART RESTART (client_id 0 = local reboot, >0 = unicast); dashboard and CLI hooks; delayed esp_restart after response.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-19 22:33:22 +02:00
co-authored by Cursor
parent 5c3cf65bca
commit a9e08107b4
23 changed files with 625 additions and 61 deletions
+26 -4
View File
@@ -21,7 +21,8 @@ typedef enum _alox_EspNowMessageType {
alox_EspNowMessageType_ESPNOW_OTA_PAYLOAD = 7,
alox_EspNowMessageType_ESPNOW_OTA_END = 8,
alox_EspNowMessageType_ESPNOW_OTA_STATUS = 9,
alox_EspNowMessageType_ESPNOW_FIND_ME = 10
alox_EspNowMessageType_ESPNOW_FIND_ME = 10,
alox_EspNowMessageType_ESPNOW_RESTART = 11
} alox_EspNowMessageType;
/* Struct definitions */
@@ -35,6 +36,11 @@ typedef struct _alox_EspNowFindMe {
uint32_t client_id;
} alox_EspNowFindMe;
/* * Master → slave: reboot after short delay. */
typedef struct _alox_EspNowRestart {
uint32_t client_id;
} alox_EspNowRestart;
typedef struct _alox_EspNowDiscover {
uint32_t network;
} alox_EspNowDiscover;
@@ -91,6 +97,7 @@ typedef struct _alox_EspNowMessage {
alox_EspNowOtaEnd ota_end;
alox_EspNowOtaStatus ota_status;
alox_EspNowFindMe find_me;
alox_EspNowRestart restart;
} payload;
} alox_EspNowMessage;
@@ -101,8 +108,9 @@ extern "C" {
/* Helper constants for enums */
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_FIND_ME
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_FIND_ME+1))
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_RESTART
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_RESTART+1))
@@ -119,6 +127,7 @@ extern "C" {
/* Initializer values for message structs */
#define alox_EspNowUnicastTest_init_default {0}
#define alox_EspNowFindMe_init_default {0}
#define alox_EspNowRestart_init_default {0}
#define alox_EspNowDiscover_init_default {0}
#define alox_EspNowSlavePresence_init_default {0, {{NULL}, NULL}, 0, 0, 0, 0}
#define alox_EspNowAccelDeadzone_init_default {0, 0}
@@ -129,6 +138,7 @@ extern "C" {
#define alox_EspNowMessage_init_default {_alox_EspNowMessageType_MIN, 0, {alox_EspNowDiscover_init_default}}
#define alox_EspNowUnicastTest_init_zero {0}
#define alox_EspNowFindMe_init_zero {0}
#define alox_EspNowRestart_init_zero {0}
#define alox_EspNowDiscover_init_zero {0}
#define alox_EspNowSlavePresence_init_zero {0, {{NULL}, NULL}, 0, 0, 0, 0}
#define alox_EspNowAccelDeadzone_init_zero {0, 0}
@@ -141,6 +151,7 @@ extern "C" {
/* Field tags (for use in manual encoding/decoding) */
#define alox_EspNowUnicastTest_seq_tag 1
#define alox_EspNowFindMe_client_id_tag 1
#define alox_EspNowRestart_client_id_tag 1
#define alox_EspNowDiscover_network_tag 1
#define alox_EspNowSlavePresence_network_tag 1
#define alox_EspNowSlavePresence_mac_tag 2
@@ -167,6 +178,7 @@ extern "C" {
#define alox_EspNowMessage_ota_end_tag 9
#define alox_EspNowMessage_ota_status_tag 10
#define alox_EspNowMessage_find_me_tag 11
#define alox_EspNowMessage_restart_tag 12
/* Struct field encoding specification for nanopb */
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
@@ -179,6 +191,11 @@ X(a, STATIC, SINGULAR, UINT32, client_id, 1)
#define alox_EspNowFindMe_CALLBACK NULL
#define alox_EspNowFindMe_DEFAULT NULL
#define alox_EspNowRestart_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
#define alox_EspNowRestart_CALLBACK NULL
#define alox_EspNowRestart_DEFAULT NULL
#define alox_EspNowDiscover_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, network, 1)
#define alox_EspNowDiscover_CALLBACK NULL
@@ -234,7 +251,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,ota_start,payload.ota_start), 7) \
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_payload,payload.ota_payload), 8) \
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_end,payload.ota_end), 9) \
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_status,payload.ota_status), 10) \
X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11)
X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11) \
X(a, STATIC, ONEOF, MESSAGE, (payload,restart,payload.restart), 12)
#define alox_EspNowMessage_CALLBACK NULL
#define alox_EspNowMessage_DEFAULT NULL
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
@@ -247,9 +265,11 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11)
#define alox_EspNowMessage_payload_ota_end_MSGTYPE alox_EspNowOtaEnd
#define alox_EspNowMessage_payload_ota_status_MSGTYPE alox_EspNowOtaStatus
#define alox_EspNowMessage_payload_find_me_MSGTYPE alox_EspNowFindMe
#define alox_EspNowMessage_payload_restart_MSGTYPE alox_EspNowRestart
extern const pb_msgdesc_t alox_EspNowUnicastTest_msg;
extern const pb_msgdesc_t alox_EspNowFindMe_msg;
extern const pb_msgdesc_t alox_EspNowRestart_msg;
extern const pb_msgdesc_t alox_EspNowDiscover_msg;
extern const pb_msgdesc_t alox_EspNowSlavePresence_msg;
extern const pb_msgdesc_t alox_EspNowAccelDeadzone_msg;
@@ -262,6 +282,7 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define alox_EspNowUnicastTest_fields &alox_EspNowUnicastTest_msg
#define alox_EspNowFindMe_fields &alox_EspNowFindMe_msg
#define alox_EspNowRestart_fields &alox_EspNowRestart_msg
#define alox_EspNowDiscover_fields &alox_EspNowDiscover_msg
#define alox_EspNowSlavePresence_fields &alox_EspNowSlavePresence_msg
#define alox_EspNowAccelDeadzone_fields &alox_EspNowAccelDeadzone_msg
@@ -282,6 +303,7 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
#define alox_EspNowOtaPayload_size 209
#define alox_EspNowOtaStart_size 6
#define alox_EspNowOtaStatus_size 18
#define alox_EspNowRestart_size 6
#define alox_EspNowUnicastTest_size 6
#ifdef __cplusplus