Merge pull request #2113 from meshtastic/mqtt-fix

Find the downlink channel to post packet to.
This commit is contained in:
Thomas Göttgens
2023-01-10 20:49:18 +01:00
committed by GitHub
4 changed files with 47 additions and 22 deletions

View File

@@ -210,7 +210,7 @@ Channel &Channels::getByIndex(ChannelIndex chIndex)
Channel &Channels::getByName(const char* chName)
{
for (ChannelIndex i = 0; i < getNumChannels(); i++) {
if (strcasecmp(channelFile.channels[i].settings.name, chName) == 0) {
if (strcasecmp(getGlobalId(i), chName) == 0) {
return channelFile.channels[i];
}
}

View File

@@ -55,11 +55,13 @@ static int32_t reconnectWiFi()
// Make sure we clear old connection credentials
WiFi.disconnect(false, true);
LOG_INFO("Reconnecting to WiFi access point %s\n",wifiName);
WiFi.mode(WIFI_MODE_STA);
WiFi.begin(wifiName, wifiPsw);
delay(5000);
if (!WiFi.isConnected()) {
WiFi.begin(wifiName, wifiPsw);
}
}
#ifndef DISABLE_NTP
@@ -167,7 +169,7 @@ bool initWifi()
WiFi.mode(WIFI_MODE_STA);
WiFi.setHostname(ourHost);
WiFi.onEvent(WiFiEvent);
WiFi.setAutoReconnect(false);
WiFi.setAutoReconnect(true);
WiFi.setSleep(false);
if (config.network.address_mode == Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) {
WiFi.config(config.network.ipv4_config.ip,
@@ -182,7 +184,8 @@ bool initWifi()
WiFi.onEvent(
[](WiFiEvent_t event, WiFiEventInfo_t info) {
LOG_WARN("WiFi lost connection. Reason: %d", info.wifi_sta_disconnected.reason);
LOG_WARN("WiFi lost connection. Reason: %d\n", info.wifi_sta_disconnected.reason);
/*
If we are disconnected from the AP for some reason,