Don't need to check all channels if not using default frequency slot

pull/3365/head
GUVWAF 2024-03-10 16:04:59 +01:00
rodzic b45a912409
commit cb7407e06b
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -257,8 +257,8 @@ const char *Channels::getName(size_t chIndex)
bool Channels::hasDefaultChannel()
{
// If we don't use a preset or we override the frequency, we don't have a default channel
if (!config.lora.use_preset || config.lora.override_frequency)
// If we don't use a preset or the default frequency slot, or we override the frequency, we don't have a default channel
if (!config.lora.use_preset || !RadioInterface::uses_default_frequency_slot || config.lora.override_frequency)
return false;
// Check if any of the channels are using the default name and PSK
for (size_t i = 0; i < getNumChannels(); i++) {
@ -266,8 +266,8 @@ bool Channels::hasDefaultChannel()
if (ch.settings.psk.size == 1 && ch.settings.psk.bytes[0] == 1) {
const char *name = getName(i);
const char *presetName = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
// Check if the name is the default derived from the modem preset and we use the default frequency slot
if (strcmp(name, presetName) == 0 && RadioInterface::uses_default_frequency_slot)
// Check if the name is the default derived from the modem preset
if (strcmp(name, presetName) == 0)
return true;
}
}