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
+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" */