From 8f609524bda17154ec6290a570ad83ab5e82263e Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 15:41:32 +1100 Subject: [PATCH] * companion: added new PUSH_CODE_LOG_RX_DATA (0x88) for inspecting all received packets --- examples/companion_radio/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index ea5efc5e..dd3b9e32 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -184,6 +184,7 @@ static uint32_t _atoi(const char* sp) { #define PUSH_CODE_LOGIN_SUCCESS 0x85 #define PUSH_CODE_LOGIN_FAIL 0x86 #define PUSH_CODE_STATUS_RESPONSE 0x87 +#define PUSH_CODE_LOG_RX_DATA 0x88 /* -------------------------------------------------------------------------------------- */ @@ -435,6 +436,24 @@ protected: return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time); } + void logRx(mesh::Packet* pkt, int len, float score) override { + if (_serial->isConnected()) { + int i = 0; + out_frame[i++] = PUSH_CODE_LOG_RX_DATA; + out_frame[i++] = (int8_t)(_radio->getLastSNR() * 4); + out_frame[i++] = (int8_t)(_radio->getLastRSSI()); + if (pkt->isRouteFlood()) { + out_frame[i++] = pkt->path_len; + memcpy(&out_frame[i], pkt->path, pkt->path_len); i += pkt->path_len; + } else { + out_frame[i++] = 0xFF; + } + memcpy(&out_frame[i], pkt->payload, pkt->payload_len); i += pkt->payload_len; + + _serial->writeFrame(out_frame, i); + } + } + void onDiscoveredContact(ContactInfo& contact, bool is_new) override { if (_serial->isConnected()) { out_frame[0] = PUSH_CODE_ADVERT;