fix #577 don't make invalid radio settings reboot the board

instead raise a critical fault (note though: this is still not ideal
because the radio will be in an undefined state until valid settings
are used)
This commit is contained in:
Kevin Hester
2020-12-27 13:09:20 +08:00
parent 21570fc24f
commit 186a52172c
4 changed files with 18 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
#include "SX1262Interface.h"
#include "error.h"
#include <configuration.h>
// Particular boards might define a different max power based on what their hardware can do
@@ -78,13 +79,13 @@ bool SX1262Interface::reconfigure()
// configure publicly accessible settings
int err = lora.setSpreadingFactor(sf);
assert(err == ERR_NONE);
if(err != ERR_NONE) recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
err = lora.setBandwidth(bw);
assert(err == ERR_NONE);
if(err != ERR_NONE) recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
err = lora.setCodingRate(cr);
assert(err == ERR_NONE);
if(err != ERR_NONE) recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
err = lora.setRxGain(true);
@@ -100,7 +101,7 @@ bool SX1262Interface::reconfigure()
assert(err == ERR_NONE);
err = lora.setFrequency(freq);
assert(err == ERR_NONE);
if(err != ERR_NONE) recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
if (power > 22) // This chip has lower power limits than some
power = 22;