Skip to content

Commit

Permalink
Don't need to check all channels if not using default frequency slot
Browse files Browse the repository at this point in the history
  • Loading branch information
GUVWAF committed Mar 10, 2024
1 parent b45a912 commit cb7407e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mesh/Channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,17 @@ 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++) {
const auto &ch = getByIndex(i);
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;
}
}
Expand Down

0 comments on commit cb7407e

Please sign in to comment.