Fix SX126x daemon abort when Tx power exceeds chip limit (#10711)
* Fix SX126x daemon abort when tx power exceeds chip limit
reconfigure() asserted on setOutputPower() failure. `power` is derived from
operator-settable config (tx_power, SX126X_MAX_POWER); a value above the SX126x
RadioLib limit (+22 dBm) returns RADIOLIB_ERR_INVALID_OUTPUT_POWER. The assert
aborts meshtasticd mid-reconfigure -- before reloadConfig() persists the change --
so the offending config silently reverts and the daemon crash-loops. Record a
critical error and continue instead, matching the adjacent setFrequency() handling.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Address Copilot review: per-chip power limit, log requested power
- Comment no longer states a universal "+22 dBm for SX126x"; notes the
limit is the driver's max (e.g. +22 on SX1262/SX1268, lower on SX1261).
- Log the rejected `power` value and that the previous Tx power is retained,
so the invalid setting and the resulting config/radio drift are visible.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Address CodeRabbit nit: trim inline comment to repo guideline
Collapse the setOutputPower failure rationale from six lines to two,
per the repo's "one or two lines at most" comment guideline. The full
incident history lives in the PR and issue #10710.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Convert pre-existing em-dashes to ASCII (trunk ascii-dash)
Two em-dashes in this file (from bbcc35e) fail the repo's ascii-dash
formatter once the file is in a PR's modified set. `trunk fmt` rewrites
them to ASCII hyphens; applied here so the Trunk Check passes. No
functional change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
co-authored by
GitHub
Claude Opus 4.8
Ben Meadors
parent
18d64bf544
commit
dee94e0758
@@ -251,11 +251,14 @@ template <typename T> bool SX126xInterface<T>::reconfigure()
|
|||||||
power = -9;
|
power = -9;
|
||||||
|
|
||||||
err = lora.setOutputPower(power);
|
err = lora.setOutputPower(power);
|
||||||
if (err != RADIOLIB_ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE) {
|
||||||
LOG_ERROR("SX126X setOutputPower %s%d", radioLibErr, err);
|
// Don't abort: this power is operator config (tx_power/SX126X_MAX_POWER); a value above the
|
||||||
assert(err == RADIOLIB_ERR_NONE);
|
// driver's max would crash the daemon before reloadConfig() persists. Flag it and keep prior power.
|
||||||
|
LOG_ERROR("SX126X setOutputPower %d dBm rejected (%s%d); keeping previous Tx power", power, radioLibErr, err);
|
||||||
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
// Apply RX gain mode — valid in STDBY (datasheet §9.6), matches resetAGC() pattern
|
// Apply RX gain mode - valid in STDBY (datasheet §9.6), matches resetAGC() pattern
|
||||||
err = lora.setRxBoostedGainMode(config.lora.sx126x_rx_boosted_gain);
|
err = lora.setRxBoostedGainMode(config.lora.sx126x_rx_boosted_gain);
|
||||||
if (err != RADIOLIB_ERR_NONE)
|
if (err != RADIOLIB_ERR_NONE)
|
||||||
LOG_WARN("SX126X setRxBoostedGainMode %s%d", radioLibErr, err);
|
LOG_WARN("SX126X setRxBoostedGainMode %s%d", radioLibErr, err);
|
||||||
@@ -426,7 +429,7 @@ template <typename T> void SX126xInterface<T>::resetAGC()
|
|||||||
|
|
||||||
LOG_DEBUG("SX126x AGC reset: warm sleep + Calibrate(0x7F)");
|
LOG_DEBUG("SX126x AGC reset: warm sleep + Calibrate(0x7F)");
|
||||||
|
|
||||||
// 1. Warm sleep — powers down the entire analog frontend, resetting AGC state.
|
// 1. Warm sleep - powers down the entire analog frontend, resetting AGC state.
|
||||||
// A plain standby→startReceive cycle does NOT reset the AGC.
|
// A plain standby→startReceive cycle does NOT reset the AGC.
|
||||||
lora.sleep(true);
|
lora.sleep(true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user