diff --git a/sonoff/support.ino b/sonoff/support.ino index 234764791..540191855 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -767,15 +767,6 @@ uint8_t ValidGPIO(uint8_t pin, uint8_t gpio) return result; } -void AppDelay(void) -{ - if (APP_BAUDRATE == baudrate) { // When baudrate too low it will fail on Sonoff Pow R2 and S31 serial interface initialization - if (global_state.wifi_down) { - delay(DRIVER_BOOT_DELAY); - } - } -} - /*********************************************************************************************\ * Sleep aware time scheduler functions borrowed from ESPEasy \*********************************************************************************************/ diff --git a/sonoff/support_wifi.ino b/sonoff/support_wifi.ino index 4a7902303..87ff4e21b 100644 --- a/sonoff/support_wifi.ino +++ b/sonoff/support_wifi.ino @@ -584,3 +584,11 @@ void EspRestart(void) } */ +void WifiAddDelayWhenDisconnected(void) +{ + if (APP_BAUDRATE == baudrate) { // When baudrate too low it will fail on Sonoff Pow R2 and S31 serial interface initialization + if (global_state.wifi_down) { + delay(DRIVER_BOOT_DELAY); + } + } +} diff --git a/sonoff/xdrv_interface.ino b/sonoff/xdrv_interface.ino index 12b9e2711..0ec3696d9 100644 --- a/sonoff/xdrv_interface.ino +++ b/sonoff/xdrv_interface.ino @@ -238,7 +238,7 @@ boolean XdrvCall(byte Function) boolean result = false; for (byte x = 0; x < xdrv_present; x++) { -// AppDelay(); +// WifiAddDelayWhenDisconnected(); result = xdrv_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xsns_interface.ino b/sonoff/xsns_interface.ino index fbe8bf218..d39995be9 100644 --- a/sonoff/xsns_interface.ino +++ b/sonoff/xsns_interface.ino @@ -278,7 +278,7 @@ boolean XsnsNextCall(byte Function, uint8_t &xsns_index) if (xsns_index == xsns_present) { xsns_index = 0; } } #endif -// AppDelay(); +// WifiAddDelayWhenDisconnected(); return xsns_func_ptr[xsns_index](Function); } @@ -298,7 +298,7 @@ boolean XsnsCall(byte Function) #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND uint32_t profile_start_millis = millis(); #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND -// AppDelay(); +// WifiAddDelayWhenDisconnected(); result = xsns_func_ptr[x](Function); #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND