Skip to content

Small fixes: airtime fallback underflow, LLCC68 wrapper build, CLI gps crash, host test build - #8

Open
mmmorks wants to merge 1 commit into
staging/meshcore-devfrom
pr/09-shared-fixes
Open

Small fixes: airtime fallback underflow, LLCC68 wrapper build, CLI gps crash, host test build#8
mmmorks wants to merge 1 commit into
staging/meshcore-devfrom
pr/09-shared-fixes

Conversation

@mmmorks

@mmmorks mmmorks commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Staged on the fork for review. Final destination: meshcore-dev/MeshCore dev (or the fork; to decide). Base here is staging/meshcore-dev so the diff shows only this change.

Summary

Five small, independent fixes, each self-contained in its own commit hunk.

calcMaxPacketMillis() fallback underflow (src/helpers/radiolib/RadioLibWrappers.cpp). When getTimeOnAir() returns nothing usable (it returns 0 on an unconfigured modem) the fallback said "4 secs" but used 4000 - preamble_us, i.e. 4 ms minus a preamble that exceeds it at every setting there is. The unsigned subtraction underflows, and the result is not a mis-sized deadline but the absence of one: a ~49-day payload watchdog leaves CustomSX1262::isReceiving() holding a latched HEADER_VALID true forever, so the channel never again reads idle. The fallback is now a flat 4 s of payload (MAX_PACKET_FALLBACK_PAYLOAD_US, overridable) with no subtraction left to underflow.

CustomLLCC68Wrapper::doResetAGC() does not compile. It calls sx126xResetAGC() with one argument; the only overload takes (SX126x*, bool rx_boost_gain). Nothing in the tree currently includes this wrapper, which is why no build has failed, but the first board to use it will. Pass getRxBoostedGainMode() like the SX1262/SX1268/STM32WLx wrappers do.

gps CLI command crashes when no GPS was detected (src/helpers/CommonCLI.cpp). The status branch does strcmp(_sensors->getSettingByKey("gps"), "1"), and getSettingByKey() returns NULL when no gps setting is registered — which is the case whenever gps_detected was false at boot. Treat a missing setting as "deactivated".

Failed-receive diagnostics (RadioLibWrappers.cpp). The readData() error line now also prints the packet length, RSSI and SNR (quarter-dB, the same convention as Packet::_snr). The modem writes its packet-status registers whether or not the CRC passed, so this costs no extra SPI traffic and is enough to tell a failure distribution sitting on the SF's SNR floor apart from one spread across strong signals (a collision pattern).

Host test build. ConfigSerializer.cpp uses atoi/atol/atof and reaches them through Arduino.h on MCU targets, but not in the native googletest environment: on macOS the whole suite fails to compile at ConfigSerializer.o. Include <stdlib.h>. Likewise LocationProvider::sendSentence() was declared virtual but never defined; every current subclass overrides it, so MCU links get away with it, but any translation unit that emits the base vtable gets an undefined reference. Give it an empty default body, matching the no-op override in EnvironmentSensorManager.cpp.

How it was tested

  • pio test -e native: all suites pass on macOS (before the <stdlib.h> fix none of them compile there).
  • Compiled for heltec_tracker_v2_repeater (ESP32-S3) and WioTrackerL1_repeater (nRF52).

Dependencies

Independent. Applies to dev.

…host tests

Five small independent fixes.

calcMaxPacketMillis()'s fallback said "4 secs" and used 4000 - preamble_us,
i.e. 4 ms minus a preamble that exceeds it at every setting there is. The
unsigned subtraction underflows, and the result is not a mis-sized deadline
but the absence of one: a ~49-day payload watchdog leaves
CustomSX1262::isReceiving() holding a latched HEADER_VALID true forever, so
the channel never again reads idle. The fallback is now a flat 4 s of
payload (MAX_PACKET_FALLBACK_PAYLOAD_US, overridable), with no subtraction
left to underflow. It is only reached when getTimeOnAir() returns nothing
usable, which it does on an unconfigured modem.

CustomLLCC68Wrapper::doResetAGC() calls sx126xResetAGC() with one argument;
the only overload takes (SX126x*, bool rx_boost_gain). Nothing in the tree
includes this wrapper yet, which is why no build has failed, but the first
board to use it will. Pass getRxBoostedGainMode() like the SX1262, SX1268
and STM32WLx wrappers do.

The bare `gps` CLI command crashes when no GPS was detected: the status
branch does strcmp(_sensors->getSettingByKey("gps"), "1") and
getSettingByKey() returns NULL when no "gps" setting is registered, which
is the case whenever gps_detected was false at boot. Treat a missing
setting as "deactivated".

recvRaw()'s readData() error line now also prints the packet length, RSSI
and SNR (quarter-dB, the same convention as Packet::_snr). The bare error
code says nothing about the cause -- a packet at the edge of the
demodulator and one lost to a collision both produce -7 -- and both
existing packet loggers sit inside the success branch, so a failed receive
is otherwise invisible to `log start` and MESH_PACKET_LOGGING alike. The
modem's packet-status registers are written whether or not the CRC passed,
so this costs no extra SPI traffic. 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.

ConfigSerializer.cpp calls atoi/atol/atof and reaches them through
Arduino.h on MCU targets, but not in the host `native` googletest build:
on macOS the whole suite fails to compile at ConfigSerializer.o, taking
every unit test down with it. Include <stdlib.h>. Likewise
LocationProvider::sendSentence() was declared virtual but never defined;
every current subclass overrides it so MCU links get away with it, but a
translation unit that emits the base vtable gets an undefined reference.
Give it an empty default body, matching the no-op override in
EnvironmentSensorManager.cpp.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXSCjgNEbJfHwLjD2WSHW4
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