From 7965ada5c503e319f4d13af4fe8563cf4487cddd Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 18 Aug 2019 15:21:38 +0200 Subject: [PATCH] Clean code Clean code --- sonoff/support_wifi.ino | 16 ---------------- sonoff/xdrv_interface.ino | 1 - sonoff/xsns_interface.ino | 19 ++++++++++++------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/sonoff/support_wifi.ino b/sonoff/support_wifi.ino index f81fa5660..e528e51ea 100644 --- a/sonoff/support_wifi.ino +++ b/sonoff/support_wifi.ino @@ -609,19 +609,3 @@ void EspRestart(void) // ESP.restart(); // This results in exception 3 on restarts on core 2.3.0 ESP.reset(); } - -/* -void EspRestart(void) -{ - ESP.restart(); -} -*/ - -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 d3e173c28..4028335c9 100644 --- a/sonoff/xdrv_interface.ino +++ b/sonoff/xdrv_interface.ino @@ -881,7 +881,6 @@ bool XdrvCall(uint8_t Function) bool result = false; for (uint32_t x = 0; x < xdrv_present; x++) { -// WifiAddDelayWhenDisconnected(); result = xdrv_func_ptr[x](Function); if (result && ((FUNC_COMMAND == Function) || diff --git a/sonoff/xsns_interface.ino b/sonoff/xsns_interface.ino index ac22e918f..cf469f930 100644 --- a/sonoff/xsns_interface.ino +++ b/sonoff/xsns_interface.ino @@ -870,13 +870,19 @@ bool XsnsNextCall(uint8_t Function, uint8_t &xsns_index) { xsns_index++; if (xsns_index == xsns_present) { xsns_index = 0; } -#ifdef USE_DEBUG_DRIVER - while (!XsnsEnabled(xsns_index) && !xsns_index) { // Perform at least first sensor (counter) - xsns_index++; - if (xsns_index == xsns_present) { xsns_index = 0; } + +#ifndef USE_DEBUG_DRIVER + if (FUNC_WEB_SENSOR == Function) { // Skip web info for disabled sensors +#endif + uint32_t max_disabled = xsns_present; + while (!XsnsEnabled(xsns_index) && max_disabled--) { // Perform at least one sensor + xsns_index++; + if (xsns_index == xsns_present) { xsns_index = 0; } + } +#ifndef USE_DEBUG_DRIVER } #endif -// WifiAddDelayWhenDisconnected(); + return xsns_func_ptr[xsns_index](Function); } @@ -890,7 +896,7 @@ bool XsnsCall(uint8_t Function) for (uint32_t x = 0; x < xsns_present; x++) { #ifdef USE_DEBUG_DRIVER - if (XsnsEnabled(x)) { + if (XsnsEnabled(x)) { // Skip disabled sensor in debug mode #endif if ((FUNC_WEB_SENSOR == Function) && !XsnsEnabled(x)) { continue; } // Skip web info for disabled sensors @@ -898,7 +904,6 @@ bool XsnsCall(uint8_t Function) #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND uint32_t profile_start_millis = millis(); #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND -// WifiAddDelayWhenDisconnected(); result = xsns_func_ptr[x](Function); #ifdef PROFILE_XSNS_SENSOR_EVERY_SECOND