Fix improve wrong ip address

This commit is contained in:
Theo Arends 2022-04-03 16:45:08 +02:00
parent 8588340bff
commit 4cb6dc2f58
3 changed files with 8 additions and 10 deletions

View File

@ -379,18 +379,16 @@ String WifiGetIPv6(void)
#endif // LWIP_IPV6=1
// Check to see if we have any routable IP address
inline bool WifiCheck_hasIP(IPAddress const & ip_address)
{
bool WifiHasIP(void) {
#ifdef LWIP2_IPV6
return !a.isLocal();
#else
return static_cast<uint32_t>(ip_address) != 0;
return (uint32_t)WiFi.localIP() != 0;
#endif
}
void WifiCheckIp(void)
{
if ((WL_CONNECTED == WiFi.status()) && WifiCheck_hasIP(WiFi.localIP())) {
void WifiCheckIp(void) {
if ((WL_CONNECTED == WiFi.status()) && WifiHasIP()) {
WifiSetState(1);
Wifi.counter = WIFI_CHECK_SEC;
Wifi.retry = Wifi.retry_init;
@ -520,7 +518,7 @@ void WifiCheck(uint8_t param)
Wifi.counter = WIFI_CHECK_SEC;
WifiCheckIp();
}
if ((WL_CONNECTED == WiFi.status()) && WifiCheck_hasIP(WiFi.localIP()) && !Wifi.config_type) {
if ((WL_CONNECTED == WiFi.status()) && WifiHasIP() && !Wifi.config_type) {
WifiSetState(1);
if (Settings->flag3.use_wifi_rescan) { // SetOption57 - Scan wifi network every 44 minutes for configured AP's
if (!(TasmotaGlobal.uptime % (60 * WIFI_RESCAN_MINUTES))) {

View File

@ -105,7 +105,7 @@ const char HTTP_SCRIPT_WIFI[] PROGMEM =
"}";
const char HTTP_SCRIPT_HIDE[] PROGMEM =
"function hidBtns() {"
"function hidBtns(){"
"eb('butmo').style.display='none';"
"eb('butmod').style.display='none';"
"eb('but0').style.display='block';"
@ -3549,7 +3549,7 @@ bool Xdrv01(uint8_t function)
if (Web.wifi_test_counter) {
Web.wifi_test_counter--;
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_TRYING_TO_CONNECT " %s"), SettingsText(SET_STASSID1));
if ( WifiCheck_hasIP(WiFi.localIP()) ) { // Got IP - Connection Established
if (WifiHasIP()) { // Got IP - Connection Established
Web.wifi_test_AP_TIMEOUT = false;
Web.wifi_test_counter = 0;
Web.wifiTest = WIFI_TEST_FINISHED;

View File

@ -293,7 +293,7 @@ void ImprovEverySecond(void) {
if (Improv.wifi_timeout) {
Improv.wifi_timeout--;
if (Improv.wifi_timeout < IMPROV_WIFI_TIMEOUT -3) { // Tasmota restarts after ssid or password change
if ((!TasmotaGlobal.global_state.wifi_down)) {
if (WifiHasIP()) {
Improv.wifi_timeout = 0;
if (IMPROV_STATE_AUTHORIZED == RtcSettings.improv_state) {
RtcSettings.improv_state = IMPROV_STATE_PROVISIONED;