Fix LR2021 TempRadio with incompatible extra-SF detectors
Temporarily disable incompatible cached side detectors while applying a temporary primary tuple, preserving their saved configuration for normal restoration. Use primary-only CAD while those detectors are suspended. Keep compatible temporary detectors and real hardware errors intact. Report pending TempRadio starts instead of off, preserve live-tuple status during replacements and future schedules, and include the two-second delay in the accepted reply. Share primary validation to retain STM32 Mini flash capacity without dropping features. Validated production CLI status, scheduler and persistence cases; LR2021 detector suspension, restoration, CAD and hardware-error paths; reply handoff, room/sensor recovery, Morse and OTA automation regressions. W12 repeater, room-server and sensor builds pass. Canonical STM32 Mini Repeater passes flash and runtime RAM admission with 436 bytes of flash remaining. Physical W12 RF testing remains unverified.
This commit is contained in:
1 parent
6ad3e349ac
commit
a87b2a33a3
12 files changed
+244
-12
No files matched your search
@@ -3541,6 +3541,10 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
return;
|
||||
}
|
||||
if (!strcmp(command, "get tempradio") || !strcmp(command, "tempradio")) {
|
||||
if (_callbacks->isTempRadioPending()) {
|
||||
strcpy(reply, "> pending");
|
||||
return;
|
||||
}
|
||||
const auto* radio = _callbacks->getProfileRadio();
|
||||
if (!radio || !radio->profiles() || !radio->profiles()->primary_temporary) strcpy(reply, "> off");
|
||||
else {
|
||||
@@ -3816,15 +3820,13 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
+ (uint64_t)temp_timeout_mins * 60 <= UINT32_MAX
|
||||
&& mesh::cli::parseDecimalStrict(parts[0], freq)
|
||||
&& mesh::cli::parseDecimalStrict(parts[1], bw)
|
||||
&& freq >= 150.0f && freq <= 2500.0f
|
||||
&& sf >= 5 && sf <= 12 && cr >= 5 && cr <= 8
|
||||
&& isValidLoRaBandwidth(bw)
|
||||
&& _radio_profiles.acceptsPrimary(freq, bw, sf, cr, preamble)) {
|
||||
&& sf <= 12 && cr <= 8
|
||||
&& acceptsPrimaryRadioParams(freq, bw, sf, cr, preamble)) {
|
||||
_callbacks->applyTempRadioParams(freq, bw, sf, cr, temp_timeout_mins, preamble);
|
||||
char duration[64];
|
||||
const uint32_t seconds = (uint32_t)temp_timeout_mins * 60UL;
|
||||
mesh::RepeaterRadioTiming::formatDuration(duration, sizeof(duration), seconds);
|
||||
snprintf(reply, 160, "OK - temp params for %s", duration);
|
||||
snprintf(reply, 160, "OK - temp params for %s; applying in 2s", duration);
|
||||
_radio_profiles.appendPrimaryChirpWarning(reply, 160, sf, bw, preamble);
|
||||
_callbacks->appendTempRadioTimingNote(reply, 160, seconds);
|
||||
appendRxPowerSavingAdjustmentNote(reply, _prefs, sf, bw);
|
||||
|
||||
@@ -607,6 +607,8 @@ public:
|
||||
virtual bool saveIdentity(const mesh::LocalIdentity& new_id) = 0;
|
||||
virtual void clearStats() = 0;
|
||||
virtual void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins, uint16_t preamble = 0) = 0;
|
||||
// Status is pending only when no temporary primary tuple is already running.
|
||||
virtual bool isTempRadioPending() const { return false; }
|
||||
virtual uint32_t getTempRadioDurationSeconds() const { return 0; }
|
||||
virtual void appendTempRadioTimingNote(char* reply, size_t size, uint32_t seconds) const { }
|
||||
// Cancel pending/active temporary-radio windows and restore the saved tuple
|
||||
|
||||
@@ -199,6 +199,12 @@ protected:
|
||||
return ((CustomLR2021 *)_radio)->setSideDetector(nullptr, 0) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
if (!mesh::lr2021::validateSideDetectorSFs(_sideDetSFs, _numSideDet, primary_sf, bw)) {
|
||||
// Extra SFs belong to the saved receive tuple. A temporary primary can
|
||||
// make that list illegal; suspend it without discarding the saved set.
|
||||
// Applying the normal tuple enables the same detectors again.
|
||||
if (_profiles.primary_temporary) {
|
||||
return ((CustomLR2021 *)_radio)->setSideDetector(nullptr, 0) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
LR2021LoRaSideDetector_t config[mesh::lr2021::MAX_SIDE_DETECTORS] = {};
|
||||
@@ -214,6 +220,12 @@ protected:
|
||||
const uint8_t rx_primary_sf = getSpreadingFactor();
|
||||
float bw = _params_valid ? _cur_bw : radio->getBandwidthKhz();
|
||||
if (bw <= 0.0f) bw = static_cast<float>(LORA_BW);
|
||||
// Incompatible saved detectors are suspended for TempRadio. CAD must scan
|
||||
// only the running primary, not the inactive detector list in the cache.
|
||||
if (_profiles.primary_temporary && !mesh::lr2021::validateSideDetectorSFs(
|
||||
_sideDetSFs, _numSideDet, rx_primary_sf, bw)) {
|
||||
return RadioLibWrapper::performChannelScan();
|
||||
}
|
||||
|
||||
int16_t status = radio->standby();
|
||||
if (status != RADIOLIB_ERR_NONE) return status;
|
||||
|
||||
Reference in new issue
Block a user