diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 23bbe3dc2..f664eb7a6 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,6 +1,6 @@ /* 6.3.0.7 20181111 * Fix wifi connection errors using wifi disconnect and ESP.reset instead of ESP.restart - * Fix Sonoff Pow R2 and Sonoff S31 Serial interface hang caused by MP3 driver + * Fix Sonoff Pow R2 and Sonoff S31 Serial interface hang caused by Sonoff Basic R2 driver delay implementation (and possibly core bug) * * 6.3.0.6 20181110 * Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40% diff --git a/sonoff/support.ino b/sonoff/support.ino index 9389714ec..0c5203d69 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -765,6 +765,15 @@ uint8_t ValidGPIO(uint8_t pin, uint8_t gpio) return result; } +void AppDelay() +{ + 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/xdrv_interface.ino b/sonoff/xdrv_interface.ino index 0f0171e20..cb3a69c22 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++) { - if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } + AppDelay(); result = xdrv_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xsns_interface.ino b/sonoff/xsns_interface.ino index a3cf4d772..723e8f070 100644 --- a/sonoff/xsns_interface.ino +++ b/sonoff/xsns_interface.ino @@ -568,7 +568,7 @@ boolean XsnsNextCall(byte Function) xsns_index++; if (xsns_index == xsns_present) { xsns_index = 0; } } - if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } + AppDelay(); return xsns_func_ptr[xsns_index](Function); } @@ -586,7 +586,7 @@ boolean XsnsCall(byte Function) #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND uint32_t profile_start_millis = millis(); #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND - if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } + AppDelay(); result = xsns_func_ptr[x](Function); #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND