Added ECHO cmd and fixed some timing issues
This commit is contained in:
@@ -29,7 +29,9 @@ typedef enum _alox_EspNowMessageType {
|
||||
alox_EspNowMessageType_ESPNOW_BATTERY_QUERY = 15,
|
||||
alox_EspNowMessageType_ESPNOW_BATTERY_REPORT = 16,
|
||||
alox_EspNowMessageType_ESPNOW_SET_TAP_NOTIFY = 17,
|
||||
alox_EspNowMessageType_ESPNOW_TAP_EVENT = 18
|
||||
alox_EspNowMessageType_ESPNOW_TAP_EVENT = 18,
|
||||
alox_EspNowMessageType_ESPNOW_ECHO_PING = 19,
|
||||
alox_EspNowMessageType_ESPNOW_ECHO_PONG = 20
|
||||
} alox_EspNowMessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@@ -37,6 +39,19 @@ typedef struct _alox_EspNowUnicastTest {
|
||||
uint32_t seq;
|
||||
} alox_EspNowUnicastTest;
|
||||
|
||||
/* * Master → slave: echo ping (host ts + master monotonic time for RTT). */
|
||||
typedef struct _alox_EspNowEchoPing {
|
||||
uint64_t host_timestamp_us;
|
||||
/* * esp_timer_get_time() (µs since boot) when master forwarded this message. */
|
||||
uint64_t master_time_us;
|
||||
} alox_EspNowEchoPing;
|
||||
|
||||
/* * Slave → master: echo ping payload unchanged. */
|
||||
typedef struct _alox_EspNowEchoPong {
|
||||
uint64_t host_timestamp_us;
|
||||
uint64_t master_time_us;
|
||||
} alox_EspNowEchoPong;
|
||||
|
||||
/* * Master → slave: locate pod (LED ring R/G/B ×3 @ full brightness). */
|
||||
typedef struct _alox_EspNowFindMe {
|
||||
/* * 0 = any slave; otherwise only slave_id must match */
|
||||
@@ -50,6 +65,8 @@ typedef struct _alox_EspNowRestart {
|
||||
|
||||
typedef struct _alox_EspNowDiscover {
|
||||
uint32_t network;
|
||||
/* * Master is in an OTA session (UART upload or ESP-NOW distribution). */
|
||||
bool master_ota_pending;
|
||||
} alox_EspNowDiscover;
|
||||
|
||||
typedef struct _alox_EspNowSlavePresence {
|
||||
@@ -169,6 +186,8 @@ typedef struct _alox_EspNowMessage {
|
||||
alox_EspNowBatteryReport battery_report;
|
||||
alox_EspNowTapNotify tap_notify;
|
||||
alox_EspNowTapEvent tap_event;
|
||||
alox_EspNowEchoPing echo_ping;
|
||||
alox_EspNowEchoPong echo_pong;
|
||||
} payload;
|
||||
} alox_EspNowMessage;
|
||||
|
||||
@@ -179,8 +198,10 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_TAP_EVENT
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_TAP_EVENT+1))
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_ECHO_PONG
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_ECHO_PONG+1))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -204,9 +225,11 @@ extern "C" {
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define alox_EspNowUnicastTest_init_default {0}
|
||||
#define alox_EspNowEchoPing_init_default {0, 0}
|
||||
#define alox_EspNowEchoPong_init_default {0, 0}
|
||||
#define alox_EspNowFindMe_init_default {0}
|
||||
#define alox_EspNowRestart_init_default {0}
|
||||
#define alox_EspNowDiscover_init_default {0}
|
||||
#define alox_EspNowDiscover_init_default {0, 0}
|
||||
#define alox_EspNowSlavePresence_init_default {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_default {0, 0}
|
||||
#define alox_EspNowAccelStream_init_default {0, 0}
|
||||
@@ -222,9 +245,11 @@ extern "C" {
|
||||
#define alox_EspNowOtaStatus_init_default {0, 0, 0}
|
||||
#define alox_EspNowMessage_init_default {_alox_EspNowMessageType_MIN, 0, {alox_EspNowDiscover_init_default}}
|
||||
#define alox_EspNowUnicastTest_init_zero {0}
|
||||
#define alox_EspNowEchoPing_init_zero {0, 0}
|
||||
#define alox_EspNowEchoPong_init_zero {0, 0}
|
||||
#define alox_EspNowFindMe_init_zero {0}
|
||||
#define alox_EspNowRestart_init_zero {0}
|
||||
#define alox_EspNowDiscover_init_zero {0}
|
||||
#define alox_EspNowDiscover_init_zero {0, 0}
|
||||
#define alox_EspNowSlavePresence_init_zero {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_zero {0, 0}
|
||||
#define alox_EspNowAccelStream_init_zero {0, 0}
|
||||
@@ -242,9 +267,14 @@ extern "C" {
|
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
#define alox_EspNowUnicastTest_seq_tag 1
|
||||
#define alox_EspNowEchoPing_host_timestamp_us_tag 1
|
||||
#define alox_EspNowEchoPing_master_time_us_tag 2
|
||||
#define alox_EspNowEchoPong_host_timestamp_us_tag 1
|
||||
#define alox_EspNowEchoPong_master_time_us_tag 2
|
||||
#define alox_EspNowFindMe_client_id_tag 1
|
||||
#define alox_EspNowRestart_client_id_tag 1
|
||||
#define alox_EspNowDiscover_network_tag 1
|
||||
#define alox_EspNowDiscover_master_ota_pending_tag 2
|
||||
#define alox_EspNowSlavePresence_network_tag 1
|
||||
#define alox_EspNowSlavePresence_mac_tag 2
|
||||
#define alox_EspNowSlavePresence_version_tag 3
|
||||
@@ -306,6 +336,8 @@ extern "C" {
|
||||
#define alox_EspNowMessage_battery_report_tag 17
|
||||
#define alox_EspNowMessage_tap_notify_tag 18
|
||||
#define alox_EspNowMessage_tap_event_tag 19
|
||||
#define alox_EspNowMessage_echo_ping_tag 20
|
||||
#define alox_EspNowMessage_echo_pong_tag 21
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
|
||||
@@ -313,6 +345,18 @@ X(a, STATIC, SINGULAR, UINT32, seq, 1)
|
||||
#define alox_EspNowUnicastTest_CALLBACK NULL
|
||||
#define alox_EspNowUnicastTest_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowEchoPing_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT64, host_timestamp_us, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT64, master_time_us, 2)
|
||||
#define alox_EspNowEchoPing_CALLBACK NULL
|
||||
#define alox_EspNowEchoPing_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowEchoPong_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT64, host_timestamp_us, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT64, master_time_us, 2)
|
||||
#define alox_EspNowEchoPong_CALLBACK NULL
|
||||
#define alox_EspNowEchoPong_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowFindMe_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowFindMe_CALLBACK NULL
|
||||
@@ -324,7 +368,8 @@ X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowRestart_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowDiscover_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, network, 1)
|
||||
X(a, STATIC, SINGULAR, UINT32, network, 1) \
|
||||
X(a, STATIC, SINGULAR, BOOL, master_ota_pending, 2)
|
||||
#define alox_EspNowDiscover_CALLBACK NULL
|
||||
#define alox_EspNowDiscover_DEFAULT NULL
|
||||
|
||||
@@ -442,7 +487,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring,payload.led_ring), 15) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_query,payload.battery_query), 16) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,battery_report,payload.battery_report), 17) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_notify,payload.tap_notify), 18) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_event,payload.tap_event), 19)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_event,payload.tap_event), 19) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,echo_ping,payload.echo_ping), 20) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,echo_pong,payload.echo_pong), 21)
|
||||
#define alox_EspNowMessage_CALLBACK NULL
|
||||
#define alox_EspNowMessage_DEFAULT NULL
|
||||
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
|
||||
@@ -463,8 +510,12 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,tap_event,payload.tap_event), 19)
|
||||
#define alox_EspNowMessage_payload_battery_report_MSGTYPE alox_EspNowBatteryReport
|
||||
#define alox_EspNowMessage_payload_tap_notify_MSGTYPE alox_EspNowTapNotify
|
||||
#define alox_EspNowMessage_payload_tap_event_MSGTYPE alox_EspNowTapEvent
|
||||
#define alox_EspNowMessage_payload_echo_ping_MSGTYPE alox_EspNowEchoPing
|
||||
#define alox_EspNowMessage_payload_echo_pong_MSGTYPE alox_EspNowEchoPong
|
||||
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowEchoPing_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowEchoPong_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;
|
||||
@@ -485,6 +536,8 @@ 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_EspNowEchoPing_fields &alox_EspNowEchoPing_msg
|
||||
#define alox_EspNowEchoPong_fields &alox_EspNowEchoPong_msg
|
||||
#define alox_EspNowFindMe_fields &alox_EspNowFindMe_msg
|
||||
#define alox_EspNowRestart_fields &alox_EspNowRestart_msg
|
||||
#define alox_EspNowDiscover_fields &alox_EspNowDiscover_msg
|
||||
@@ -512,7 +565,9 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
#define alox_EspNowAccelStream_size 8
|
||||
#define alox_EspNowBatteryQuery_size 6
|
||||
#define alox_EspNowBatteryReport_size 22
|
||||
#define alox_EspNowDiscover_size 6
|
||||
#define alox_EspNowDiscover_size 8
|
||||
#define alox_EspNowEchoPing_size 22
|
||||
#define alox_EspNowEchoPong_size 22
|
||||
#define alox_EspNowFindMe_size 6
|
||||
#define alox_EspNowLedRing_size 60
|
||||
#define alox_EspNowOtaEnd_size 0
|
||||
|
||||
Reference in New Issue
Block a user