mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 06:32:06 +00:00
Fall back to default modem preset if requested bandwidth is too large (#4497)
This commit is contained in:
parent
e3e36e23f9
commit
7a65c8838d
@ -412,6 +412,8 @@ void RadioInterface::applyModemConfig()
|
|||||||
// Set up default configuration
|
// Set up default configuration
|
||||||
// No Sync Words in LORA mode
|
// No Sync Words in LORA mode
|
||||||
meshtastic_Config_LoRaConfig &loraConfig = config.lora;
|
meshtastic_Config_LoRaConfig &loraConfig = config.lora;
|
||||||
|
bool validConfig = false; // We need to check for a valid configuration
|
||||||
|
while (!validConfig) {
|
||||||
if (loraConfig.use_preset) {
|
if (loraConfig.use_preset) {
|
||||||
|
|
||||||
switch (loraConfig.modem_preset) {
|
switch (loraConfig.modem_preset) {
|
||||||
@ -480,6 +482,25 @@ void RadioInterface::applyModemConfig()
|
|||||||
bw = 1625.0;
|
bw = 1625.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((myRegion->freqEnd - myRegion->freqStart) < bw / 1000) {
|
||||||
|
static const char *err_string =
|
||||||
|
"Regional frequency range is smaller than bandwidth. Falling back to default preset.\n";
|
||||||
|
LOG_ERROR(err_string);
|
||||||
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
||||||
|
|
||||||
|
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||||
|
cn->level = meshtastic_LogRecord_Level_ERROR;
|
||||||
|
sprintf(cn->message, err_string);
|
||||||
|
service->sendClientNotification(cn);
|
||||||
|
|
||||||
|
// Set to default modem preset
|
||||||
|
loraConfig.use_preset = true;
|
||||||
|
loraConfig.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
|
||||||
|
} else {
|
||||||
|
validConfig = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
power = loraConfig.tx_power;
|
power = loraConfig.tx_power;
|
||||||
|
|
||||||
if ((power == 0) || ((power + REGULATORY_GAIN_LORA > myRegion->powerLimit) && !devicestate.owner.is_licensed))
|
if ((power == 0) || ((power + REGULATORY_GAIN_LORA > myRegion->powerLimit) && !devicestate.owner.is_licensed))
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
#include "PointerQueue.h"
|
#include "PointerQueue.h"
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
#define MAX_TX_QUEUE 16 // max number of packets which can be waiting for transmission
|
#define MAX_TX_QUEUE 16 // max number of packets which can be waiting for transmission
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user