Skip to content

Log packet length, RSSI and SNR when readData() fails - #15

Open
mmmorks wants to merge 1 commit into
staging/meshcore-devfrom
pr/09d-readdata-diagnostics
Open

Log packet length, RSSI and SNR when readData() fails#15
mmmorks wants to merge 1 commit into
staging/meshcore-devfrom
pr/09d-readdata-diagnostics

Conversation

@mmmorks

@mmmorks mmmorks commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Summary

recvRaw()'s readData() error line prints only the error code, which says nothing about the cause: a packet at the edge of the demodulator and one lost to a collision both produce -7 (CRC mismatch). Both existing packet loggers sit inside the success branch, so a failed receive is invisible to log start and MESH_PACKET_LOGGING alike.

The modem's packet-status registers are written whether or not the CRC passed, so reading them here costs no extra SPI traffic and reports the same values a successful receive would. SNR is scaled by 4 rather than truncated, because the threshold this is meant to resolve is a fraction of a dB wide and %f is not portable across every platform this file builds for — the same quarter-dB convention as Packet::_snr.

Why it is worth having

Measured on a live repeater at SF7/62.5 kHz — 490 failures against 961 successes over 25 minutes — the failure rate resolves into a clean waterfall against SNR, with 20% of failures at positive SNR where marginality cannot be the explanation. That distinction is not available from the error code alone.

This is debug output: the line is inside MESH_DEBUG_PRINTLN and costs nothing on a build without MESH_DEBUG.

How it was tested

  • pio test -e native: all suites pass.
  • Compiled for meshnology_w12_repeater (ESP32-S3).

Dependencies

Independent. Applies to dev.

recvRaw()'s readData() error line prints only the error code, which says
nothing about the cause: a packet at the edge of the demodulator and one
lost to a collision both produce -7 (CRC mismatch). Both existing packet
loggers sit inside the success branch, so a failed receive is invisible to
`log start` and MESH_PACKET_LOGGING alike.

The modem's packet-status registers are written whether or not the CRC
passed, so reading them here costs no extra SPI traffic and reports the same
values a successful receive would. SNR is scaled by 4 rather than truncated,
because the threshold this is meant to resolve is a fraction of a dB wide
and %f is not portable across every platform this file builds for -- the
same quarter-dB convention as Packet::_snr.

Measured on a live repeater at SF7/62.5 kHz (490 failures against 961
successes over 25 min), the failure rate resolves into a clean waterfall
against SNR, with 20% of failures at positive SNR where marginality cannot
be the explanation.

Debug output only: the line is inside MESH_DEBUG_PRINTLN and costs nothing
on a build without MESH_DEBUG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant