Skip to content

Commit f77a694

Browse files
author
Scott Powell
committed
* PUSH_CODE_LOG_RX_DATA: is now just: {snr*4},{rssi},{raw-lora-packet}
1 parent 8f60952 commit f77a694

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

examples/companion_radio/main.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -436,19 +436,13 @@ class MyMesh : public BaseChatMesh {
436436
return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time);
437437
}
438438

439-
void logRx(mesh::Packet* pkt, int len, float score) override {
439+
void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override {
440440
if (_serial->isConnected()) {
441441
int i = 0;
442442
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;
443+
out_frame[i++] = (int8_t)(snr * 4);
444+
out_frame[i++] = (int8_t)(rssi);
445+
memcpy(&out_frame[i], raw, len); i += len;
452446

453447
_serial->writeFrame(out_frame, i);
454448
}

src/Dispatcher.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ void Dispatcher::checkRecv() {
7878
float score;
7979
uint32_t air_time;
8080
{
81-
uint8_t raw[MAX_TRANS_UNIT];
81+
uint8_t raw[MAX_TRANS_UNIT+1];
8282
int len = _radio->recvRaw(raw, MAX_TRANS_UNIT);
8383
if (len > 0) {
84+
logRxRaw(_radio->getLastSNR(), _radio->getLastRSSI(), raw, len);
85+
8486
pkt = _mgr->allocNew();
8587
if (pkt == NULL) {
8688
MESH_DEBUG_PRINTLN("%s Dispatcher::checkRecv(): WARNING: received data, no unused packets available!", getLogDateTime());

src/Dispatcher.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ class Dispatcher {
117117

118118
virtual DispatcherAction onRecvPacket(Packet* pkt) = 0;
119119

120+
virtual void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) { } // custom hook
121+
120122
virtual void logRx(Packet* packet, int len, float score) { } // hooks for custom logging
121123
virtual void logTx(Packet* packet, int len) { }
122124
virtual void logTxFail(Packet* packet, int len) { }

0 commit comments

Comments
 (0)