Skip to content

Commit 8f60952

Browse files
author
Scott Powell
committed
* companion: added new PUSH_CODE_LOG_RX_DATA (0x88) for inspecting all received packets
1 parent c49e6ac commit 8f60952

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/companion_radio/main.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static uint32_t _atoi(const char* sp) {
184184
#define PUSH_CODE_LOGIN_SUCCESS 0x85
185185
#define PUSH_CODE_LOGIN_FAIL 0x86
186186
#define PUSH_CODE_STATUS_RESPONSE 0x87
187+
#define PUSH_CODE_LOG_RX_DATA 0x88
187188

188189
/* -------------------------------------------------------------------------------------- */
189190

@@ -435,6 +436,24 @@ class MyMesh : public BaseChatMesh {
435436
return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time);
436437
}
437438

439+
void logRx(mesh::Packet* pkt, int len, float score) override {
440+
if (_serial->isConnected()) {
441+
int i = 0;
442+
out_frame[i++] = PUSH_CODE_LOG_RX_DATA;
443+
out_frame[i++] = (int8_t)(_radio->getLastSNR() * 4);
444+
out_frame[i++] = (int8_t)(_radio->getLastRSSI());
445+
if (pkt->isRouteFlood()) {
446+
out_frame[i++] = pkt->path_len;
447+
memcpy(&out_frame[i], pkt->path, pkt->path_len); i += pkt->path_len;
448+
} else {
449+
out_frame[i++] = 0xFF;
450+
}
451+
memcpy(&out_frame[i], pkt->payload, pkt->payload_len); i += pkt->payload_len;
452+
453+
_serial->writeFrame(out_frame, i);
454+
}
455+
}
456+
438457
void onDiscoveredContact(ContactInfo& contact, bool is_new) override {
439458
if (_serial->isConnected()) {
440459
out_frame[0] = PUSH_CODE_ADVERT;

0 commit comments

Comments
 (0)