Fix ESP-NOW unicast by using sender MAC in client registry.

Register slaves from recv src_addr instead of protobuf mac bytes, add
ESPNOW_UNICAST_TEST for path verification, restore unicast deadzone, and
expose unicast-test in goTool.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-18 23:15:03 +02:00
co-authored by Cursor
parent ee38ce551a
commit 241e82b35b
20 changed files with 585 additions and 102 deletions
+1
View File
@@ -17,6 +17,7 @@ idf_component_register(
"cmd_version.c"
"cmd_client_info.c"
"cmd_accel_deadzone.c"
"cmd_espnow_unicast_test.c"
"client_registry.c"
"esp_now_comm.c"
"esp_now_proto.c"
+14 -2
View File
@@ -186,10 +186,20 @@ Filters BMA456 logs: a new accel line is emitted only when any axis changes by m
| `write` | `false` = read, `true` = write |
| `deadzone` | Threshold in LSB (write) |
| `client_id` | `0` = local sensor on this node; `>0` = slave id (master) |
| `all_clients` | Master: ESP-NOW push to every registered slave |
| `all_clients` | Master: ESP-NOW unicast to every registered slave |
**Response:** `accel_deadzone_response` with applied `deadzone`, `success`, and `slaves_updated` (ESP-NOW count).
### ESPNOW_UNICAST_TEST command
Minimal master→slave ESP-NOW unicast check (no BMA456). Use this before debugging `ACCEL_DEADZONE` unicast.
**Request:** framed `07` + `espnow_unicast_test_request` (`client_id`, `seq`).
**Response:** `espnow_unicast_test_response` (`success`, `seq`).
**Firmware logs:** master `unicast TEST to … seq=N`; slave `UNICAST TEST OK from master … seq=N`.
### CLIENT_INFO command
**Request:** framed payload `04` only (`MessageType.CLIENT_INFO`).
@@ -208,7 +218,9 @@ Fields per client: `id`, `mac`, `version`, `available`, `used`, `last_ping`, `la
| `client_registry_check_timeouts(timeout_ms)` | Mark stale clients inactive (master monitor task) |
| `client_registry_count()` / `client_registry_at(i)` | Iterate for UART encoding |
Slaves register when the master receives `SLAVE_INFO` on the matching network; `HEARTBEAT` keeps them marked available.
Slaves register when the master receives `SLAVE_INFO` on the matching network; `HEARTBEAT` keeps them marked available. The registry **MAC is always the ESP-NOW source address** (`recv_info.src_addr`), not the optional `mac` bytes in the protobuf (used only on the wire for debugging).
`slave_id` is the senders WiFi STA address last octet (`mac[5]`); it can collide across devices — use `gotool clients` and match the full MAC.
## Host tool (`goTool/`)
+18
View File
@@ -45,6 +45,22 @@ static client_slot_t *find_slot(const uint8_t mac[CLIENT_MAC_LEN]) {
return NULL;
}
static void evict_stale_id(uint32_t id, const uint8_t mac[CLIENT_MAC_LEN]) {
for (size_t i = 0; i < CLIENT_REGISTRY_MAX; i++) {
if (!s_clients[i].active || s_clients[i].info.id != id) {
continue;
}
if (mac_equal(s_clients[i].info.mac, mac)) {
continue;
}
char old_mac[18];
mac_to_str(s_clients[i].info.mac, old_mac, sizeof(old_mac));
ESP_LOGW(TAG, "dropping stale id=%lu mac=%s (now %02x:…:%02x)", (unsigned long)id,
old_mac, mac[0], mac[5]);
s_clients[i].active = false;
}
}
static client_slot_t *alloc_slot(const uint8_t mac[CLIENT_MAC_LEN],
bool *out_is_new) {
client_slot_t *slot = find_slot(mac);
@@ -98,6 +114,7 @@ esp_err_t client_registry_upsert(const uint8_t mac[CLIENT_MAC_LEN], uint32_t id,
slot->info.used = used;
slot->info.last_ping_at = ts;
slot->info.last_success_ping_at = ts;
evict_stale_id(id, mac);
if (out_is_new != NULL) {
*out_is_new = is_new;
@@ -130,6 +147,7 @@ esp_err_t client_registry_heartbeat(const uint8_t mac[CLIENT_MAC_LEN],
slot->info.available = true;
slot->info.last_ping_at = ts;
slot->info.last_success_ping_at = ts;
evict_stale_id(id, mac);
if (out_is_new != NULL) {
*out_is_new = is_new;
+16 -6
View File
@@ -38,7 +38,7 @@ static esp_err_t push_deadzone_to_slave(const client_info_t *client,
return err;
}
return esp_now_comm_send_accel_deadzone(client->id, deadzone);
return esp_now_comm_send_accel_deadzone(client->mac, client->id, deadzone);
}
static void handle_accel_deadzone(const uint8_t *data, size_t len) {
@@ -69,16 +69,26 @@ static void handle_accel_deadzone(const uint8_t *data, size_t len) {
if (req.write) {
if (req.all_clients) {
size_t n = client_registry_set_accel_deadzone_all(req.deadzone);
esp_err_t send_err = esp_now_comm_send_accel_deadzone(0, req.deadzone);
uint32_t sent = 0;
for (size_t i = 0; i < client_registry_count(); i++) {
const client_info_t *client = client_registry_at(i);
if (client == NULL) {
continue;
}
if (esp_now_comm_send_accel_deadzone(client->mac, client->id,
req.deadzone) == ESP_OK) {
sent++;
}
}
if (bma456_is_ready()) {
bma456_set_accel_deadzone(req.deadzone);
}
ESP_LOGI(TAG, "set deadzone %lu broadcast (registry %u)",
(unsigned long)req.deadzone, (unsigned)n);
send_response(req.deadzone, 0, send_err == ESP_OK || bma456_is_ready(),
send_err == ESP_OK ? (uint32_t)n : 0);
ESP_LOGI(TAG, "set deadzone %lu via unicast to %u/%u slaves",
(unsigned long)req.deadzone, (unsigned)sent, (unsigned)n);
send_response(req.deadzone, 0, sent > 0 || bma456_is_ready(), sent);
return;
}
+66
View File
@@ -0,0 +1,66 @@
#include "client_registry.h"
#include "cmd_espnow_unicast_test.h"
#include "cmd_handler.h"
#include "esp_log.h"
#include "esp_now_comm.h"
#include "pb_decode.h"
#include "uart_messages.pb.h"
#include "uart_proto.h"
static const char *TAG = "[UNICAST_TEST]";
static void send_response(bool success, uint32_t seq) {
alox_UartMessage response = alox_UartMessage_init_zero;
response.type = alox_MessageType_ESPNOW_UNICAST_TEST;
response.which_payload = alox_UartMessage_espnow_unicast_test_response_tag;
response.payload.espnow_unicast_test_response.success = success;
response.payload.espnow_unicast_test_response.seq = seq;
if (uart_send_uart_message(&response) != ESP_OK) {
ESP_LOGE(TAG, "failed to send response");
}
}
static void handle_espnow_unicast_test(const uint8_t *data, size_t len) {
alox_UartMessage uart_msg = alox_UartMessage_init_zero;
alox_EspNowUnicastTestRequest req = alox_EspNowUnicastTestRequest_init_zero;
bool have_request = false;
if (len > 0) {
pb_istream_t stream = pb_istream_from_buffer(data, len);
if (!pb_decode(&stream, alox_UartMessage_fields, &uart_msg)) {
ESP_LOGW(TAG, "decode failed");
send_response(false, 0);
return;
}
if (uart_msg.which_payload ==
alox_UartMessage_espnow_unicast_test_request_tag) {
req = uart_msg.payload.espnow_unicast_test_request;
have_request = true;
}
}
if (!have_request || req.client_id == 0) {
ESP_LOGW(TAG, "need client_id in request");
send_response(false, 0);
return;
}
const client_info_t *client = client_registry_find_by_id(req.client_id);
if (client == NULL) {
ESP_LOGW(TAG, "client id %lu not in registry",
(unsigned long)req.client_id);
send_response(false, req.seq);
return;
}
esp_err_t err = esp_now_comm_send_unicast_test(client->mac, req.seq);
send_response(err == ESP_OK, req.seq);
}
void cmd_espnow_unicast_test_register(void) {
if (msg_register_handler(alox_MessageType_ESPNOW_UNICAST_TEST,
handle_espnow_unicast_test) != ESP_OK) {
ESP_LOGE(TAG, "register failed");
}
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef CMD_ESPNOW_UNICAST_TEST_H
#define CMD_ESPNOW_UNICAST_TEST_H
void cmd_espnow_unicast_test_register(void);
#endif
+2
View File
@@ -28,6 +28,8 @@ static const char *message_type_name(uint16_t id) {
return "CLIENT_INPUT";
case alox_MessageType_ACCEL_DEADZONE:
return "ACCEL_DEADZONE";
case alox_MessageType_ESPNOW_UNICAST_TEST:
return "ESPNOW_UNICAST_TEST";
case alox_MessageType_OTA_START:
return "OTA_START";
case alox_MessageType_OTA_PAYLOAD:
+62 -14
View File
@@ -110,7 +110,8 @@ static esp_err_t send_message(const uint8_t *dest_mac,
return err;
}
static esp_err_t send_accel_deadzone(uint32_t client_id, uint32_t deadzone) {
static esp_err_t send_accel_deadzone(const uint8_t *dest_mac, uint32_t client_id,
uint32_t deadzone) {
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
msg.type = alox_EspNowMessageType_ESPNOW_SET_ACCEL_DEADZONE;
@@ -118,22 +119,50 @@ static esp_err_t send_accel_deadzone(uint32_t client_id, uint32_t deadzone) {
msg.payload.accel_deadzone.deadzone = deadzone;
msg.payload.accel_deadzone.client_id = client_id;
return send_message(ESPNOW_BCAST, &msg);
return send_message(dest_mac, &msg);
}
esp_err_t esp_now_comm_send_accel_deadzone(uint32_t client_id, uint32_t deadzone) {
if (!s_config.master) {
static esp_err_t send_unicast_test(const uint8_t *dest_mac, uint32_t seq) {
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
msg.type = alox_EspNowMessageType_ESPNOW_UNICAST_TEST;
msg.which_payload = alox_EspNowMessage_unicast_test_tag;
msg.payload.unicast_test.seq = seq;
return send_message(dest_mac, &msg);
}
esp_err_t esp_now_comm_send_unicast_test(const uint8_t mac[CLIENT_MAC_LEN],
uint32_t seq) {
if (mac == NULL || !s_config.master) {
return ESP_ERR_INVALID_STATE;
}
esp_err_t err = send_accel_deadzone(client_id, deadzone);
char mac_str[18];
mac_to_str(mac, mac_str, sizeof(mac_str));
esp_err_t err = send_unicast_test(mac, seq);
if (err == ESP_OK) {
ESP_LOGI(TAG,
"broadcast SET_ACCEL_DEADZONE deadzone=%lu client_id=%lu%s",
(unsigned long)deadzone, (unsigned long)client_id,
client_id == 0 ? " (all slaves)" : "");
ESP_LOGI(TAG, "unicast TEST to %s seq=%lu", mac_str, (unsigned long)seq);
} else {
ESP_LOGW(TAG, "broadcast SET_ACCEL_DEADZONE failed: %s",
ESP_LOGW(TAG, "unicast TEST to %s failed: %s", mac_str, esp_err_to_name(err));
}
return err;
}
esp_err_t esp_now_comm_send_accel_deadzone(const uint8_t mac[CLIENT_MAC_LEN],
uint32_t client_id, uint32_t deadzone) {
if (mac == NULL || !s_config.master) {
return ESP_ERR_INVALID_STATE;
}
char mac_str[18];
mac_to_str(mac, mac_str, sizeof(mac_str));
esp_err_t err = send_accel_deadzone(mac, client_id, deadzone);
if (err == ESP_OK) {
ESP_LOGI(TAG, "unicast SET_ACCEL_DEADZONE to %s: deadzone=%lu client_id=%lu",
mac_str, (unsigned long)deadzone, (unsigned long)client_id);
} else {
ESP_LOGW(TAG, "unicast SET_ACCEL_DEADZONE to %s failed: %s", mac_str,
esp_err_to_name(err));
}
return err;
@@ -163,6 +192,15 @@ static void slave_reset_join(void) {
s_last_discover_ms = 0;
}
static void handle_slave_unicast_test(const uint8_t *master_mac,
const alox_EspNowUnicastTest *test) {
char mac_str[18];
mac_to_str(master_mac, mac_str, sizeof(mac_str));
ESP_LOGI(TAG, "UNICAST TEST OK from master %s seq=%lu (joined=%d)",
mac_str, (unsigned long)test->seq, (int)s_slave_joined);
}
static void handle_slave_accel_deadzone(const uint8_t *master_mac,
const alox_EspNowAccelDeadzone *cfg) {
uint32_t my_id = s_own_mac[5];
@@ -192,6 +230,8 @@ static void handle_client_presence(const alox_EspNowSlavePresence *presence,
return;
}
ensure_peer(mac);
bool is_new = false;
bool reactivated = false;
esp_err_t err = client_registry_heartbeat(
@@ -309,10 +349,17 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
return;
}
if (s_slave_joined && mac_equal(info->src_addr, s_master_mac)) {
ensure_peer(info->src_addr);
}
switch (msg.which_payload) {
case alox_EspNowMessage_discover_tag:
handle_discover(info->src_addr, &msg.payload.discover);
break;
case alox_EspNowMessage_unicast_test_tag:
handle_slave_unicast_test(info->src_addr, &msg.payload.unicast_test);
break;
case alox_EspNowMessage_accel_deadzone_tag:
handle_slave_accel_deadzone(info->src_addr, &msg.payload.accel_deadzone);
break;
@@ -325,17 +372,17 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
}
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
uint8_t peer_mac[CLIENT_MAC_LEN];
if (esp_now_proto_decode_with_mac(data, (size_t)len, &msg, peer_mac) !=
ESP_OK) {
if (esp_now_proto_decode(data, (size_t)len, &msg) != ESP_OK) {
ESP_LOGW(TAG, "master: ESP-NOW decode failed (%d bytes)", len);
return;
}
const alox_EspNowSlavePresence *presence = esp_now_proto_get_presence(&msg);
if (presence != NULL) {
handle_client_presence(presence, peer_mac);
/* Registry key is the ESP-NOW sender MAC, not the optional protobuf mac field. */
ensure_peer(info->src_addr);
handle_client_presence(presence, info->src_addr);
}
}
@@ -382,6 +429,7 @@ static esp_err_t init_wifi_stack(uint8_t channel) {
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
ESP_ERROR_CHECK(esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE));
return ESP_OK;
+7 -5
View File
@@ -7,10 +7,12 @@
esp_err_t esp_now_comm_init(const app_config_t *config);
/**
* Master: broadcast accel deadzone (same path as DISCOVER).
* client_id 0 = all slaves; otherwise only the slave with that id applies it.
*/
esp_err_t esp_now_comm_send_accel_deadzone(uint32_t client_id, uint32_t deadzone);
/** Master: unicast accel deadzone to one slave (client_id is echoed for filtering). */
esp_err_t esp_now_comm_send_accel_deadzone(const uint8_t mac[CLIENT_MAC_LEN],
uint32_t client_id, uint32_t deadzone);
/** Master: send minimal unicast test payload to verify master→slave path. */
esp_err_t esp_now_comm_send_unicast_test(const uint8_t mac[CLIENT_MAC_LEN],
uint32_t seq);
#endif
+2
View File
@@ -1,6 +1,7 @@
#include "app_config.h"
#include "cmd_handler.h"
#include "cmd_accel_deadzone.h"
#include "cmd_espnow_unicast_test.h"
#include "cmd_client_info.h"
#include "cmd_version.h"
#include "esp_now_comm.h"
@@ -146,6 +147,7 @@ void app_main(void) {
cmd_version_register();
cmd_client_info_register();
cmd_accel_deadzone_register();
cmd_espnow_unicast_test_register();
}
uint8_t current_digit = 10;
+3
View File
@@ -6,6 +6,9 @@
#error Regenerate this file with the current version of nanopb generator.
#endif
PB_BIND(alox_EspNowUnicastTest, alox_EspNowUnicastTest, AUTO)
PB_BIND(alox_EspNowDiscover, alox_EspNowDiscover, AUTO)
+25 -4
View File
@@ -15,10 +15,15 @@ typedef enum _alox_EspNowMessageType {
alox_EspNowMessageType_ESPNOW_DISCOVER = 1,
alox_EspNowMessageType_ESPNOW_SLAVE_INFO = 2,
alox_EspNowMessageType_ESPNOW_HEARTBEAT = 3,
alox_EspNowMessageType_ESPNOW_SET_ACCEL_DEADZONE = 4
alox_EspNowMessageType_ESPNOW_SET_ACCEL_DEADZONE = 4,
alox_EspNowMessageType_ESPNOW_UNICAST_TEST = 5
} alox_EspNowMessageType;
/* Struct definitions */
typedef struct _alox_EspNowUnicastTest {
uint32_t seq;
} alox_EspNowUnicastTest;
typedef struct _alox_EspNowDiscover {
uint32_t network;
} alox_EspNowDiscover;
@@ -45,6 +50,7 @@ typedef struct _alox_EspNowMessage {
alox_EspNowSlavePresence slave_info;
alox_EspNowSlavePresence heartbeat;
alox_EspNowAccelDeadzone accel_deadzone;
alox_EspNowUnicastTest unicast_test;
} payload;
} alox_EspNowMessage;
@@ -55,8 +61,9 @@ extern "C" {
/* Helper constants for enums */
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_SET_ACCEL_DEADZONE
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_SET_ACCEL_DEADZONE+1))
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_UNICAST_TEST
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_UNICAST_TEST+1))
@@ -65,16 +72,19 @@ extern "C" {
/* Initializer values for message structs */
#define alox_EspNowUnicastTest_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}
#define alox_EspNowMessage_init_default {_alox_EspNowMessageType_MIN, 0, {alox_EspNowDiscover_init_default}}
#define alox_EspNowUnicastTest_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}
#define alox_EspNowMessage_init_zero {_alox_EspNowMessageType_MIN, 0, {alox_EspNowDiscover_init_zero}}
/* Field tags (for use in manual encoding/decoding) */
#define alox_EspNowUnicastTest_seq_tag 1
#define alox_EspNowDiscover_network_tag 1
#define alox_EspNowSlavePresence_network_tag 1
#define alox_EspNowSlavePresence_mac_tag 2
@@ -89,8 +99,14 @@ extern "C" {
#define alox_EspNowMessage_slave_info_tag 3
#define alox_EspNowMessage_heartbeat_tag 4
#define alox_EspNowMessage_accel_deadzone_tag 5
#define alox_EspNowMessage_unicast_test_tag 6
/* Struct field encoding specification for nanopb */
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, seq, 1)
#define alox_EspNowUnicastTest_CALLBACK NULL
#define alox_EspNowUnicastTest_DEFAULT NULL
#define alox_EspNowDiscover_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, network, 1)
#define alox_EspNowDiscover_CALLBACK NULL
@@ -117,20 +133,24 @@ X(a, STATIC, SINGULAR, UENUM, type, 1) \
X(a, STATIC, ONEOF, MESSAGE, (payload,discover,payload.discover), 2) \
X(a, STATIC, ONEOF, MESSAGE, (payload,slave_info,payload.slave_info), 3) \
X(a, STATIC, ONEOF, MESSAGE, (payload,heartbeat,payload.heartbeat), 4) \
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_deadzone,payload.accel_deadzone), 5)
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_deadzone,payload.accel_deadzone), 5) \
X(a, STATIC, ONEOF, MESSAGE, (payload,unicast_test,payload.unicast_test), 6)
#define alox_EspNowMessage_CALLBACK NULL
#define alox_EspNowMessage_DEFAULT NULL
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
#define alox_EspNowMessage_payload_slave_info_MSGTYPE alox_EspNowSlavePresence
#define alox_EspNowMessage_payload_heartbeat_MSGTYPE alox_EspNowSlavePresence
#define alox_EspNowMessage_payload_accel_deadzone_MSGTYPE alox_EspNowAccelDeadzone
#define alox_EspNowMessage_payload_unicast_test_MSGTYPE alox_EspNowUnicastTest
extern const pb_msgdesc_t alox_EspNowUnicastTest_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;
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_EspNowDiscover_fields &alox_EspNowDiscover_msg
#define alox_EspNowSlavePresence_fields &alox_EspNowSlavePresence_msg
#define alox_EspNowAccelDeadzone_fields &alox_EspNowAccelDeadzone_msg
@@ -142,6 +162,7 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
#define ALOX_MAIN_PROTO_ESP_NOW_MESSAGES_PB_H_MAX_SIZE alox_EspNowAccelDeadzone_size
#define alox_EspNowAccelDeadzone_size 12
#define alox_EspNowDiscover_size 6
#define alox_EspNowUnicastTest_size 6
#ifdef __cplusplus
} /* extern "C" */
+6
View File
@@ -8,6 +8,11 @@ enum EspNowMessageType {
ESPNOW_SLAVE_INFO = 2;
ESPNOW_HEARTBEAT = 3;
ESPNOW_SET_ACCEL_DEADZONE = 4;
ESPNOW_UNICAST_TEST = 5;
}
message EspNowUnicastTest {
uint32 seq = 1;
}
message EspNowDiscover {
@@ -35,5 +40,6 @@ message EspNowMessage {
EspNowSlavePresence slave_info = 3;
EspNowSlavePresence heartbeat = 4;
EspNowAccelDeadzone accel_deadzone = 5;
EspNowUnicastTest unicast_test = 6;
}
}
+6
View File
@@ -36,6 +36,12 @@ PB_BIND(alox_AccelDeadzoneRequest, alox_AccelDeadzoneRequest, AUTO)
PB_BIND(alox_AccelDeadzoneResponse, alox_AccelDeadzoneResponse, AUTO)
PB_BIND(alox_EspNowUnicastTestRequest, alox_EspNowUnicastTestRequest, AUTO)
PB_BIND(alox_EspNowUnicastTestResponse, alox_EspNowUnicastTestResponse, AUTO)
PB_BIND(alox_OtaStartPayload, alox_OtaStartPayload, AUTO)
+48 -1
View File
@@ -18,6 +18,7 @@ typedef enum _alox_MessageType {
alox_MessageType_CLIENT_INFO = 4,
alox_MessageType_CLIENT_INPUT = 5,
alox_MessageType_ACCEL_DEADZONE = 6,
alox_MessageType_ESPNOW_UNICAST_TEST = 7,
alox_MessageType_OTA_START = 16,
alox_MessageType_OTA_PAYLOAD = 17,
alox_MessageType_OTA_END = 18,
@@ -81,6 +82,16 @@ typedef struct _alox_AccelDeadzoneResponse {
uint32_t slaves_updated;
} alox_AccelDeadzoneResponse;
typedef struct _alox_EspNowUnicastTestRequest {
uint32_t client_id;
uint32_t seq;
} alox_EspNowUnicastTestRequest;
typedef struct _alox_EspNowUnicastTestResponse {
bool success;
uint32_t seq;
} alox_EspNowUnicastTestResponse;
typedef struct _alox_OtaStartPayload {
uint32_t total_size;
uint32_t block_size;
@@ -115,6 +126,8 @@ typedef struct _alox_UartMessage {
alox_OtaStatusPayload ota_status;
alox_AccelDeadzoneRequest accel_deadzone_request;
alox_AccelDeadzoneResponse accel_deadzone_response;
alox_EspNowUnicastTestRequest espnow_unicast_test_request;
alox_EspNowUnicastTestResponse espnow_unicast_test_response;
} payload;
} alox_UartMessage;
@@ -144,6 +157,8 @@ extern "C" {
/* Initializer values for message structs */
#define alox_UartMessage_init_default {_alox_MessageType_MIN, 0, {alox_Ack_init_default}}
#define alox_Ack_init_default {0}
@@ -155,6 +170,8 @@ extern "C" {
#define alox_ClientInputResponse_init_default {{{NULL}, NULL}}
#define alox_AccelDeadzoneRequest_init_default {0, 0, 0, 0}
#define alox_AccelDeadzoneResponse_init_default {0, 0, 0, 0}
#define alox_EspNowUnicastTestRequest_init_default {0, 0}
#define alox_EspNowUnicastTestResponse_init_default {0, 0}
#define alox_OtaStartPayload_init_default {0, 0}
#define alox_OtaPayload_init_default {0, 0, {{NULL}, NULL}}
#define alox_OtaEndPayload_init_default {0}
@@ -169,6 +186,8 @@ extern "C" {
#define alox_ClientInputResponse_init_zero {{{NULL}, NULL}}
#define alox_AccelDeadzoneRequest_init_zero {0, 0, 0, 0}
#define alox_AccelDeadzoneResponse_init_zero {0, 0, 0, 0}
#define alox_EspNowUnicastTestRequest_init_zero {0, 0}
#define alox_EspNowUnicastTestResponse_init_zero {0, 0}
#define alox_OtaStartPayload_init_zero {0, 0}
#define alox_OtaPayload_init_zero {0, 0, {{NULL}, NULL}}
#define alox_OtaEndPayload_init_zero {0}
@@ -199,6 +218,10 @@ extern "C" {
#define alox_AccelDeadzoneResponse_client_id_tag 2
#define alox_AccelDeadzoneResponse_success_tag 3
#define alox_AccelDeadzoneResponse_slaves_updated_tag 4
#define alox_EspNowUnicastTestRequest_client_id_tag 1
#define alox_EspNowUnicastTestRequest_seq_tag 2
#define alox_EspNowUnicastTestResponse_success_tag 1
#define alox_EspNowUnicastTestResponse_seq_tag 2
#define alox_OtaStartPayload_total_size_tag 1
#define alox_OtaStartPayload_block_size_tag 2
#define alox_OtaPayload_block_id_tag 1
@@ -218,6 +241,8 @@ extern "C" {
#define alox_UartMessage_ota_status_tag 10
#define alox_UartMessage_accel_deadzone_request_tag 11
#define alox_UartMessage_accel_deadzone_response_tag 12
#define alox_UartMessage_espnow_unicast_test_request_tag 13
#define alox_UartMessage_espnow_unicast_test_response_tag 14
/* Struct field encoding specification for nanopb */
#define alox_UartMessage_FIELDLIST(X, a) \
@@ -232,7 +257,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,ota_payload,payload.ota_payload),
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,accel_deadzone_request,payload.accel_deadzone_request), 11) \
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_deadzone_response,payload.accel_deadzone_response), 12)
X(a, STATIC, ONEOF, MESSAGE, (payload,accel_deadzone_response,payload.accel_deadzone_response), 12) \
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_unicast_test_request,payload.espnow_unicast_test_request), 13) \
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_unicast_test_response,payload.espnow_unicast_test_response), 14)
#define alox_UartMessage_CALLBACK NULL
#define alox_UartMessage_DEFAULT NULL
#define alox_UartMessage_payload_ack_payload_MSGTYPE alox_Ack
@@ -246,6 +273,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,accel_deadzone_response,payload.acce
#define alox_UartMessage_payload_ota_status_MSGTYPE alox_OtaStatusPayload
#define alox_UartMessage_payload_accel_deadzone_request_MSGTYPE alox_AccelDeadzoneRequest
#define alox_UartMessage_payload_accel_deadzone_response_MSGTYPE alox_AccelDeadzoneResponse
#define alox_UartMessage_payload_espnow_unicast_test_request_MSGTYPE alox_EspNowUnicastTestRequest
#define alox_UartMessage_payload_espnow_unicast_test_response_MSGTYPE alox_EspNowUnicastTestResponse
#define alox_Ack_FIELDLIST(X, a) \
@@ -310,6 +339,18 @@ X(a, STATIC, SINGULAR, UINT32, slaves_updated, 4)
#define alox_AccelDeadzoneResponse_CALLBACK NULL
#define alox_AccelDeadzoneResponse_DEFAULT NULL
#define alox_EspNowUnicastTestRequest_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
X(a, STATIC, SINGULAR, UINT32, seq, 2)
#define alox_EspNowUnicastTestRequest_CALLBACK NULL
#define alox_EspNowUnicastTestRequest_DEFAULT NULL
#define alox_EspNowUnicastTestResponse_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, BOOL, success, 1) \
X(a, STATIC, SINGULAR, UINT32, seq, 2)
#define alox_EspNowUnicastTestResponse_CALLBACK NULL
#define alox_EspNowUnicastTestResponse_DEFAULT NULL
#define alox_OtaStartPayload_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, total_size, 1) \
X(a, STATIC, SINGULAR, UINT32, block_size, 2)
@@ -343,6 +384,8 @@ extern const pb_msgdesc_t alox_ClientInput_msg;
extern const pb_msgdesc_t alox_ClientInputResponse_msg;
extern const pb_msgdesc_t alox_AccelDeadzoneRequest_msg;
extern const pb_msgdesc_t alox_AccelDeadzoneResponse_msg;
extern const pb_msgdesc_t alox_EspNowUnicastTestRequest_msg;
extern const pb_msgdesc_t alox_EspNowUnicastTestResponse_msg;
extern const pb_msgdesc_t alox_OtaStartPayload_msg;
extern const pb_msgdesc_t alox_OtaPayload_msg;
extern const pb_msgdesc_t alox_OtaEndPayload_msg;
@@ -359,6 +402,8 @@ extern const pb_msgdesc_t alox_OtaStatusPayload_msg;
#define alox_ClientInputResponse_fields &alox_ClientInputResponse_msg
#define alox_AccelDeadzoneRequest_fields &alox_AccelDeadzoneRequest_msg
#define alox_AccelDeadzoneResponse_fields &alox_AccelDeadzoneResponse_msg
#define alox_EspNowUnicastTestRequest_fields &alox_EspNowUnicastTestRequest_msg
#define alox_EspNowUnicastTestResponse_fields &alox_EspNowUnicastTestResponse_msg
#define alox_OtaStartPayload_fields &alox_OtaStartPayload_msg
#define alox_OtaPayload_fields &alox_OtaPayload_msg
#define alox_OtaEndPayload_fields &alox_OtaEndPayload_msg
@@ -377,6 +422,8 @@ extern const pb_msgdesc_t alox_OtaStatusPayload_msg;
#define alox_AccelDeadzoneResponse_size 20
#define alox_Ack_size 0
#define alox_ClientInput_size 22
#define alox_EspNowUnicastTestRequest_size 12
#define alox_EspNowUnicastTestResponse_size 8
#define alox_OtaEndPayload_size 6
#define alox_OtaStartPayload_size 12
#define alox_OtaStatusPayload_size 6
+13
View File
@@ -10,6 +10,7 @@ enum MessageType {
CLIENT_INFO = 4;
CLIENT_INPUT = 5;
ACCEL_DEADZONE = 6;
ESPNOW_UNICAST_TEST = 7;
OTA_START = 16;
OTA_PAYLOAD = 17;
OTA_END = 18;
@@ -31,6 +32,8 @@ message UartMessage {
OtaStatusPayload ota_status = 10;
AccelDeadzoneRequest accel_deadzone_request = 11;
AccelDeadzoneResponse accel_deadzone_response = 12;
EspNowUnicastTestRequest espnow_unicast_test_request = 13;
EspNowUnicastTestResponse espnow_unicast_test_response = 14;
}
}
@@ -87,6 +90,16 @@ message AccelDeadzoneResponse {
uint32 slaves_updated = 4;
}
message EspNowUnicastTestRequest {
uint32 client_id = 1;
uint32 seq = 2;
}
message EspNowUnicastTestResponse {
bool success = 1;
uint32 seq = 2;
}
message OtaStartPayload {
uint32 total_size = 1;
uint32 block_size = 2;