Skip to content

Commit 3778c0a

Browse files
author
Scott Powell
committed
* repeater and room server: MESH_PACKET_LOGGING, now dumps RAW: rx packet contents
* Dispatcher: MESH_PACKET_LOGGING, added " hash={packet-hash}"
1 parent f77a694 commit 3778c0a

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

examples/simple_repeater/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
246246
return tmp;
247247
}
248248

249+
void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override {
250+
#if MESH_PACKET_LOGGING
251+
Serial.print(getLogDateTime());
252+
Serial.print(" RAW: ");
253+
mesh::Utils::printHex(Serial, raw, len);
254+
Serial.println();
255+
#endif
256+
}
257+
249258
void logRx(mesh::Packet* pkt, int len, float score) override {
250259
if (_logging) {
251260
File f = openAppend(PACKET_LOG_FILE);

examples/simple_room_server/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
264264
return _prefs.airtime_factor;
265265
}
266266

267+
void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override {
268+
#if MESH_PACKET_LOGGING
269+
Serial.print(getLogDateTime());
270+
Serial.print(" RAW: ");
271+
mesh::Utils::printHex(Serial, raw, len);
272+
Serial.println();
273+
#endif
274+
}
275+
267276
int calcRxDelay(float score, uint32_t air_time) const override {
268277
if (_prefs.rx_delay_base <= 0.0f) return 0;
269278
return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time);

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ build_flags =
159159
-D ADVERT_LON=145.0
160160
-D ADMIN_PASSWORD="\"password\""
161161
-D ROOM_PASSWORD="\"hello\""
162-
; -D MESH_PACKET_LOGGING=1
162+
-D MESH_PACKET_LOGGING=1
163163
; -D MESH_DEBUG=1
164164

165165
[env:Heltec_v3_terminal_chat]

src/Dispatcher.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ void Dispatcher::checkRecv() {
130130
Serial.printf(": RX, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d score=%d",
131131
2 + pkt->path_len + pkt->payload_len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len,
132132
(int)_radio->getLastSNR(), (int)_radio->getLastRSSI(), (int)(score*1000));
133+
134+
static uint8_t packet_hash[MAX_HASH_SIZE];
135+
pkt->calculatePacketHash(packet_hash);
136+
Serial.print(" hash=");
137+
mesh::Utils::printHex(Serial, packet_hash, MAX_HASH_SIZE);
138+
133139
if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ
134140
|| pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) {
135141
Serial.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]);

0 commit comments

Comments
 (0)