mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 14:42:05 +00:00
Fix for "has default channel" with empty channel name (#4430)
This commit is contained in:
parent
3878e025e4
commit
debf4b934f
@ -309,12 +309,14 @@ const char *Channels::getName(size_t chIndex)
|
|||||||
return channelName;
|
return channelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Channels::isDefaultChannel(const meshtastic_Channel &ch)
|
bool Channels::isDefaultChannel(ChannelIndex chIndex)
|
||||||
{
|
{
|
||||||
|
const auto &ch = getByIndex(chIndex);
|
||||||
if (ch.settings.psk.size == 1 && ch.settings.psk.bytes[0] == 1) {
|
if (ch.settings.psk.size == 1 && ch.settings.psk.bytes[0] == 1) {
|
||||||
|
const char *name = getName(chIndex);
|
||||||
const char *presetName = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
const char *presetName = DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false);
|
||||||
// Check if the name is the default derived from the modem preset
|
// Check if the name is the default derived from the modem preset
|
||||||
if (strcmp(ch.settings.name, presetName) == 0)
|
if (strcmp(name, presetName) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -327,8 +329,7 @@ bool Channels::hasDefaultChannel()
|
|||||||
return false;
|
return false;
|
||||||
// Check if any of the channels are using the default name and PSK
|
// Check if any of the channels are using the default name and PSK
|
||||||
for (size_t i = 0; i < getNumChannels(); i++) {
|
for (size_t i = 0; i < getNumChannels(); i++) {
|
||||||
const auto &ch = getByIndex(i);
|
if (isDefaultChannel(i))
|
||||||
if (isDefaultChannel(ch))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -84,7 +84,7 @@ class Channels
|
|||||||
int16_t setActiveByIndex(ChannelIndex channelIndex);
|
int16_t setActiveByIndex(ChannelIndex channelIndex);
|
||||||
|
|
||||||
// Returns true if the channel has the default name and PSK
|
// Returns true if the channel has the default name and PSK
|
||||||
bool isDefaultChannel(const meshtastic_Channel &ch);
|
bool isDefaultChannel(ChannelIndex chIndex);
|
||||||
|
|
||||||
// Returns true if we can be reached via a channel with the default settings given a region and modem preset
|
// Returns true if we can be reached via a channel with the default settings given a region and modem preset
|
||||||
bool hasDefaultChannel();
|
bool hasDefaultChannel();
|
||||||
@ -129,4 +129,4 @@ class Channels
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Singleton channel table
|
/// Singleton channel table
|
||||||
extern Channels channels;
|
extern Channels channels;
|
@ -382,7 +382,7 @@ ProcessMessage StoreForwardModule::handleReceived(const meshtastic_MeshPacket &m
|
|||||||
LOG_DEBUG("*** Legacy Request to send\n");
|
LOG_DEBUG("*** Legacy Request to send\n");
|
||||||
|
|
||||||
// Send the last 60 minutes of messages.
|
// Send the last 60 minutes of messages.
|
||||||
if (this->busy || channels.isDefaultChannel(channels.getByIndex(mp.channel))) {
|
if (this->busy || channels.isDefaultChannel(mp.channel)) {
|
||||||
sendErrorTextMessage(getFrom(&mp), mp.decoded.want_response);
|
sendErrorTextMessage(getFrom(&mp), mp.decoded.want_response);
|
||||||
} else {
|
} else {
|
||||||
storeForwardModule->historySend(historyReturnWindow * 60, getFrom(&mp));
|
storeForwardModule->historySend(historyReturnWindow * 60, getFrom(&mp));
|
||||||
@ -447,7 +447,7 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
|
|||||||
requests_history++;
|
requests_history++;
|
||||||
LOG_INFO("*** Client Request to send HISTORY\n");
|
LOG_INFO("*** Client Request to send HISTORY\n");
|
||||||
// Send the last 60 minutes of messages.
|
// Send the last 60 minutes of messages.
|
||||||
if (this->busy || channels.isDefaultChannel(channels.getByIndex(mp.channel))) {
|
if (this->busy || channels.isDefaultChannel(mp.channel)) {
|
||||||
sendErrorTextMessage(getFrom(&mp), mp.decoded.want_response);
|
sendErrorTextMessage(getFrom(&mp), mp.decoded.want_response);
|
||||||
} else {
|
} else {
|
||||||
if ((p->which_variant == meshtastic_StoreAndForward_history_tag) && (p->variant.history.window > 0)) {
|
if ((p->which_variant == meshtastic_StoreAndForward_history_tag) && (p->variant.history.window > 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user