Added ECHO cmd and fixed some timing issues

This commit is contained in:
2026-06-06 17:44:40 +02:00
parent 35ce1476d8
commit ac223ada72
29 changed files with 1182 additions and 152 deletions
+62 -4
View File
@@ -32,7 +32,9 @@ typedef enum _alox_MessageType {
alox_MessageType_BATTERY_STATUS = 26,
alox_MessageType_TAP_NOTIFY = 27,
/* * Combined cached accel + tap poll (one UART round-trip, ~16 ms cadence). */
alox_MessageType_CACHE_STATUS = 29
alox_MessageType_CACHE_STATUS = 29,
/* * Host → master → slave → master: timestamp echo round-trip (latency test). */
alox_MessageType_ESPNOW_ECHO_PING = 30
} alox_MessageType;
typedef enum _alox_TapKind {
@@ -235,6 +237,22 @@ typedef struct _alox_EspNowUnicastTestResponse {
uint32_t seq;
} alox_EspNowUnicastTestResponse;
/* * Host → master: ESP-NOW echo ping to one slave (timestamp echoed back). */
typedef struct _alox_EspNowEchoPingRequest {
uint32_t client_id;
/* * Microseconds since Unix epoch (host clock). */
uint64_t timestamp_us;
} alox_EspNowEchoPingRequest;
typedef struct _alox_EspNowEchoPingResponse {
bool success;
uint32_t client_id;
/* * Echoed host timestamp from goTool request. */
uint64_t timestamp_us;
/* * esp_timer_get_time() delta from ping send to pong recv (master→slave→master). */
uint32_t esp_rtt_us;
} alox_EspNowEchoPingResponse;
/* Host → master: LED ring on master (client_id=0) and/or slaves via ESP-NOW.
mode: 0=clear, 1=progress (0100 %), 2=digit (010), 3=blink, 4=find-me, 5=all LEDs solid color. */
typedef struct _alox_LedRingProgressRequest {
@@ -371,6 +389,8 @@ typedef struct _alox_UartMessage {
alox_TapNotifyResponse tap_notify_response;
alox_CacheStatusRequest cache_status_request;
alox_CacheStatusResponse cache_status_response;
alox_EspNowEchoPingRequest espnow_echo_ping_request;
alox_EspNowEchoPingResponse espnow_echo_ping_response;
} payload;
} alox_UartMessage;
@@ -381,8 +401,8 @@ extern "C" {
/* Helper constants for enums */
#define _alox_MessageType_MIN alox_MessageType_UNKNOWN
#define _alox_MessageType_MAX alox_MessageType_CACHE_STATUS
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_CACHE_STATUS+1))
#define _alox_MessageType_MAX alox_MessageType_ESPNOW_ECHO_PING
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_ESPNOW_ECHO_PING+1))
#define _alox_TapKind_MIN alox_TapKind_TAP_NONE
#define _alox_TapKind_MAX alox_TapKind_TAP_TRIPLE
@@ -431,6 +451,8 @@ extern "C" {
/* Initializer values for message structs */
#define alox_UartMessage_init_default {_alox_MessageType_MIN, 0, {alox_Ack_init_default}}
@@ -460,6 +482,8 @@ extern "C" {
#define alox_CacheStatusResponse_init_default {0, {alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default, alox_CacheClientStatus_init_default}}
#define alox_EspNowUnicastTestRequest_init_default {0, 0}
#define alox_EspNowUnicastTestResponse_init_default {0, 0}
#define alox_EspNowEchoPingRequest_init_default {0, 0}
#define alox_EspNowEchoPingResponse_init_default {0, 0, 0, 0}
#define alox_LedRingProgressRequest_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define alox_LedRingProgressResponse_init_default {0, 0, 0, 0, 0, 0}
#define alox_EspNowFindMeRequest_init_default {0}
@@ -500,6 +524,8 @@ extern "C" {
#define alox_CacheStatusResponse_init_zero {0, {alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero, alox_CacheClientStatus_init_zero}}
#define alox_EspNowUnicastTestRequest_init_zero {0, 0}
#define alox_EspNowUnicastTestResponse_init_zero {0, 0}
#define alox_EspNowEchoPingRequest_init_zero {0, 0}
#define alox_EspNowEchoPingResponse_init_zero {0, 0, 0, 0}
#define alox_LedRingProgressRequest_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define alox_LedRingProgressResponse_init_zero {0, 0, 0, 0, 0, 0}
#define alox_EspNowFindMeRequest_init_zero {0}
@@ -599,6 +625,12 @@ extern "C" {
#define alox_EspNowUnicastTestRequest_seq_tag 2
#define alox_EspNowUnicastTestResponse_success_tag 1
#define alox_EspNowUnicastTestResponse_seq_tag 2
#define alox_EspNowEchoPingRequest_client_id_tag 1
#define alox_EspNowEchoPingRequest_timestamp_us_tag 2
#define alox_EspNowEchoPingResponse_success_tag 1
#define alox_EspNowEchoPingResponse_client_id_tag 2
#define alox_EspNowEchoPingResponse_timestamp_us_tag 3
#define alox_EspNowEchoPingResponse_esp_rtt_us_tag 4
#define alox_LedRingProgressRequest_mode_tag 1
#define alox_LedRingProgressRequest_progress_tag 2
#define alox_LedRingProgressRequest_digit_tag 3
@@ -671,6 +703,8 @@ extern "C" {
#define alox_UartMessage_tap_notify_response_tag 30
#define alox_UartMessage_cache_status_request_tag 33
#define alox_UartMessage_cache_status_response_tag 34
#define alox_UartMessage_espnow_echo_ping_request_tag 35
#define alox_UartMessage_espnow_echo_ping_response_tag 36
/* Struct field encoding specification for nanopb */
#define alox_UartMessage_FIELDLIST(X, a) \
@@ -703,7 +737,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,battery_status_response,payload.batt
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_notify_request,payload.tap_notify_request), 29) \
X(a, STATIC, ONEOF, MESSAGE, (payload,tap_notify_response,payload.tap_notify_response), 30) \
X(a, STATIC, ONEOF, MESSAGE, (payload,cache_status_request,payload.cache_status_request), 33) \
X(a, STATIC, ONEOF, MESSAGE, (payload,cache_status_response,payload.cache_status_response), 34)
X(a, STATIC, ONEOF, MESSAGE, (payload,cache_status_response,payload.cache_status_response), 34) \
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_echo_ping_request,payload.espnow_echo_ping_request), 35) \
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_echo_ping_response,payload.espnow_echo_ping_response), 36)
#define alox_UartMessage_CALLBACK NULL
#define alox_UartMessage_DEFAULT NULL
#define alox_UartMessage_payload_ack_payload_MSGTYPE alox_Ack
@@ -735,6 +771,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,cache_status_response,payload.cache_
#define alox_UartMessage_payload_tap_notify_response_MSGTYPE alox_TapNotifyResponse
#define alox_UartMessage_payload_cache_status_request_MSGTYPE alox_CacheStatusRequest
#define alox_UartMessage_payload_cache_status_response_MSGTYPE alox_CacheStatusResponse
#define alox_UartMessage_payload_espnow_echo_ping_request_MSGTYPE alox_EspNowEchoPingRequest
#define alox_UartMessage_payload_espnow_echo_ping_response_MSGTYPE alox_EspNowEchoPingResponse
#define alox_Ack_FIELDLIST(X, a) \
@@ -934,6 +972,20 @@ X(a, STATIC, SINGULAR, UINT32, seq, 2)
#define alox_EspNowUnicastTestResponse_CALLBACK NULL
#define alox_EspNowUnicastTestResponse_DEFAULT NULL
#define alox_EspNowEchoPingRequest_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, client_id, 1) \
X(a, STATIC, SINGULAR, UINT64, timestamp_us, 2)
#define alox_EspNowEchoPingRequest_CALLBACK NULL
#define alox_EspNowEchoPingRequest_DEFAULT NULL
#define alox_EspNowEchoPingResponse_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, BOOL, success, 1) \
X(a, STATIC, SINGULAR, UINT32, client_id, 2) \
X(a, STATIC, SINGULAR, UINT64, timestamp_us, 3) \
X(a, STATIC, SINGULAR, UINT32, esp_rtt_us, 4)
#define alox_EspNowEchoPingResponse_CALLBACK NULL
#define alox_EspNowEchoPingResponse_DEFAULT NULL
#define alox_LedRingProgressRequest_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, mode, 1) \
X(a, STATIC, SINGULAR, UINT32, progress, 2) \
@@ -1057,6 +1109,8 @@ extern const pb_msgdesc_t alox_CacheClientStatus_msg;
extern const pb_msgdesc_t alox_CacheStatusResponse_msg;
extern const pb_msgdesc_t alox_EspNowUnicastTestRequest_msg;
extern const pb_msgdesc_t alox_EspNowUnicastTestResponse_msg;
extern const pb_msgdesc_t alox_EspNowEchoPingRequest_msg;
extern const pb_msgdesc_t alox_EspNowEchoPingResponse_msg;
extern const pb_msgdesc_t alox_LedRingProgressRequest_msg;
extern const pb_msgdesc_t alox_LedRingProgressResponse_msg;
extern const pb_msgdesc_t alox_EspNowFindMeRequest_msg;
@@ -1099,6 +1153,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
#define alox_CacheStatusResponse_fields &alox_CacheStatusResponse_msg
#define alox_EspNowUnicastTestRequest_fields &alox_EspNowUnicastTestRequest_msg
#define alox_EspNowUnicastTestResponse_fields &alox_EspNowUnicastTestResponse_msg
#define alox_EspNowEchoPingRequest_fields &alox_EspNowEchoPingRequest_msg
#define alox_EspNowEchoPingResponse_fields &alox_EspNowEchoPingResponse_msg
#define alox_LedRingProgressRequest_fields &alox_LedRingProgressRequest_msg
#define alox_LedRingProgressResponse_fields &alox_LedRingProgressResponse_msg
#define alox_EspNowFindMeRequest_fields &alox_EspNowFindMeRequest_msg
@@ -1136,6 +1192,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
#define alox_CacheStatusRequest_size 0
#define alox_CacheStatusResponse_size 736
#define alox_ClientInput_size 22
#define alox_EspNowEchoPingRequest_size 17
#define alox_EspNowEchoPingResponse_size 25
#define alox_EspNowFindMeRequest_size 6
#define alox_EspNowFindMeResponse_size 8
#define alox_EspNowUnicastTestRequest_size 12