diff --git a/src/comms.cpp b/src/comms.cpp index 59a07c8..392a2c8 100644 --- a/src/comms.cpp +++ b/src/comms.cpp @@ -560,24 +560,30 @@ void passwordcrypt() { } void tryWiFi() { - if (!setupmode) { + if (!setupmode && wifi) { tft.drawRoundRect(1, 60, 319, 140, 5, ActiveColor); tft.fillRoundRect(3, 62, 315, 136, 5, BackgroundColor); tftPrint(0, myLanguage[language][55], 155, 88, ActiveColor, ActiveColorSmooth, 28); } - if (wc.autoConnect()) { - Server.begin(); - Udp.begin(9031); - remoteip = IPAddress (WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient); - if (!setupmode) tftPrint(0, myLanguage[language][57], 155, 128, InsignificantColor, InsignificantColorSmooth, 28); - wifi = true; + if (wifi) { + if (wc.autoConnect()) { + Server.begin(); + Udp.begin(9031); + remoteip = IPAddress (WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], subnetclient); + if (!setupmode) tftPrint(0, myLanguage[language][57], 155, 128, InsignificantColor, InsignificantColorSmooth, 28); + wifi = true; + } else { + if (!setupmode) tftPrint(0, myLanguage[language][56], 155, 128, SignificantColor, SignificantColorSmooth, 28); + Server.end(); + Udp.stop(); + WiFi.mode(WIFI_OFF); + wifi = false; + XDRGTKTCP = false; + RDSSPYTCP = false; + } } else { - if (!setupmode) tftPrint(0, myLanguage[language][56], 155, 128, SignificantColor, SignificantColorSmooth, 28); Server.end(); Udp.stop(); WiFi.mode(WIFI_OFF); - wifi = false; - XDRGTKTCP = false; - RDSSPYTCP = false; } -} +} \ No newline at end of file diff --git a/src/gui.cpp b/src/gui.cpp index 9bbef4c..37d183b 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -2268,9 +2268,9 @@ void DoMenu() { break; } } else { - if (menupage == CONNECTIVITY && menuoption == ITEM2 && wifi) { + if (menupage == CONNECTIVITY && menuoption == ITEM2) { tryWiFi(); - delay(2000); + if (wifi) delay(2000); } if (menupage == DISPLAYSETTINGS && menuoption == ITEM5) { doTheme(); @@ -2278,4 +2278,4 @@ void DoMenu() { menuopen = false; BuildMenu(); } -} +} \ No newline at end of file