mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Merge pull request #17103 from joba-1/rgx-preserve-ap-connections-on-sta-reconnect
preserve AP connections if STA side reconnects
This commit is contained in:
commit
91953e2658
@ -210,10 +210,13 @@ void WifiBegin(uint8_t flag, uint8_t channel)
|
|||||||
#endif // USE_EMULATION
|
#endif // USE_EMULATION
|
||||||
|
|
||||||
WiFi.persistent(false); // Solve possible wifi init errors (re-add at 6.2.1.16 #4044, #4083)
|
WiFi.persistent(false); // Solve possible wifi init errors (re-add at 6.2.1.16 #4044, #4083)
|
||||||
WiFi.disconnect(true); // Delete SDK wifi config
|
if (WiFi.getMode() != WIFI_AP_STA) // Preserve range extender connections
|
||||||
delay(200);
|
{
|
||||||
|
WiFi.disconnect(true); // Delete SDK wifi config
|
||||||
|
delay(200);
|
||||||
|
|
||||||
WifiSetMode(WIFI_STA); // Disable AP mode
|
WifiSetMode(WIFI_STA); // Disable AP mode
|
||||||
|
}
|
||||||
WiFiSetSleepMode();
|
WiFiSetSleepMode();
|
||||||
// if (WiFi.getPhyMode() != WIFI_PHY_MODE_11N) { WiFi.setPhyMode(WIFI_PHY_MODE_11N); } // B/G/N
|
// if (WiFi.getPhyMode() != WIFI_PHY_MODE_11N) { WiFi.setPhyMode(WIFI_PHY_MODE_11N); } // B/G/N
|
||||||
// if (WiFi.getPhyMode() != WIFI_PHY_MODE_11G) { WiFi.setPhyMode(WIFI_PHY_MODE_11G); } // B/G
|
// if (WiFi.getPhyMode() != WIFI_PHY_MODE_11G) { WiFi.setPhyMode(WIFI_PHY_MODE_11G); } // B/G
|
||||||
|
@ -142,7 +142,6 @@ void (*const DrvRgxCommand[])(void) PROGMEM = {
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8_t status = RGX_NOT_CONFIGURED;
|
uint8_t status = RGX_NOT_CONFIGURED;
|
||||||
uint16_t lastlinkcount = 0;
|
|
||||||
#ifdef USE_WIFI_RANGE_EXTENDER_NAPT
|
#ifdef USE_WIFI_RANGE_EXTENDER_NAPT
|
||||||
bool napt_enabled = false;
|
bool napt_enabled = false;
|
||||||
#endif // USE_WIFI_RANGE_EXTENDER_NAPT
|
#endif // USE_WIFI_RANGE_EXTENDER_NAPT
|
||||||
@ -369,7 +368,6 @@ void rngxSetup()
|
|||||||
WiFi.softAP(SettingsText(SET_RGX_SSID), SettingsText(SET_RGX_PASSWORD));
|
WiFi.softAP(SettingsText(SET_RGX_SSID), SettingsText(SET_RGX_PASSWORD));
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("RGX: WiFi Extender AP Enabled with SSID: %s"), WiFi.softAPSSID().c_str());
|
AddLog(LOG_LEVEL_INFO, PSTR("RGX: WiFi Extender AP Enabled with SSID: %s"), WiFi.softAPSSID().c_str());
|
||||||
RgxSettings.status = RGX_SETUP_NAPT;
|
RgxSettings.status = RGX_SETUP_NAPT;
|
||||||
RgxSettings.lastlinkcount = Wifi.link_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rngxSetupNAPT(void)
|
void rngxSetupNAPT(void)
|
||||||
@ -472,17 +470,11 @@ bool Xdrv58(uint32_t function)
|
|||||||
}
|
}
|
||||||
else if (RgxSettings.status == RGX_CONFIGURED)
|
else if (RgxSettings.status == RGX_CONFIGURED)
|
||||||
{
|
{
|
||||||
if (Wifi.status != WL_CONNECTED)
|
if (Wifi.status == WL_CONNECTED && WiFi.getMode() != WIFI_AP_STA)
|
||||||
{
|
{
|
||||||
// No longer connected, need to setup again
|
// Should not happen... our AP is gone and only a restart will get it back properly
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("RGX: No longer connected, prepare to reconnect WiFi AP..."));
|
AddLog(LOG_LEVEL_INFO, PSTR("RGX: WiFi mode is %d not %d. Restart..."), WiFi.getMode(), WIFI_AP_STA);
|
||||||
RgxSettings.status = RGX_NOT_CONFIGURED;
|
TasmotaGlobal.restart_flag = 2;
|
||||||
}
|
|
||||||
else if (RgxSettings.lastlinkcount != Wifi.link_count && WiFi.getMode() != WIFI_AP_STA)
|
|
||||||
{
|
|
||||||
// Assume WiFi has reconnected and been reconfigured, prepare to reconnect
|
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("RGX: Link count now: %d, WiFi.getMode(): %d, unconfigure..."), Wifi.link_count, WiFi.getMode());
|
|
||||||
RgxSettings.status = RGX_NOT_CONFIGURED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user