diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 9bcbbb731..a7cb1ce9a 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -173,6 +173,8 @@ typedef unsigned long power_t; // Power (Relay) type #define KNX_MAX_device_param 30 #define MAX_KNXTX_CMNDS 5 +#define DRIVER_BOOT_DELAY 1 // Number of milliseconds to retard driver cycles during boot-up time to reduce overall CPU load whilst Wifi is connecting + /*********************************************************************************************\ * Enumeration \*********************************************************************************************/ diff --git a/sonoff/xdrv_interface.ino b/sonoff/xdrv_interface.ino index a578343b4..69bbcbada 100644 --- a/sonoff/xdrv_interface.ino +++ b/sonoff/xdrv_interface.ino @@ -233,7 +233,7 @@ boolean XdrvCall(byte Function) boolean result = false; for (byte x = 0; x < xdrv_present; x++) { - if (global_state.wifi_down) { delay(1); } + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xdrv_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xdsp_interface.ino b/sonoff/xdsp_interface.ino index 8d6d5a814..a2b19ebb8 100644 --- a/sonoff/xdsp_interface.ino +++ b/sonoff/xdsp_interface.ino @@ -117,6 +117,7 @@ boolean XdspCall(byte Function) boolean result = false; for (byte x = 0; x < xdsp_present; x++) { + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xdsp_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xnrg_interface.ino b/sonoff/xnrg_interface.ino index 015d5d284..1706c4e26 100644 --- a/sonoff/xnrg_interface.ino +++ b/sonoff/xnrg_interface.ino @@ -90,6 +90,7 @@ int XnrgCall(byte Function) int result = 0; for (byte x = 0; x < xnrg_present; x++) { + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xnrg_func_ptr[x](Function); if (result) break; } diff --git a/sonoff/xsns_interface.ino b/sonoff/xsns_interface.ino index 8132b8c30..a51ab5947 100644 --- a/sonoff/xsns_interface.ino +++ b/sonoff/xsns_interface.ino @@ -273,7 +273,7 @@ boolean XsnsNextCall(byte Function) { xsns_index++; if (xsns_index == xsns_present) xsns_index = 0; - if (global_state.wifi_down) { delay(1); } + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } return xsns_func_ptr[xsns_index](Function); } @@ -290,7 +290,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(1); } + if (global_state.wifi_down) { delay(DRIVER_BOOT_DELAY); } result = xsns_func_ptr[x](Function); #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND