diff options
author | rechrtb <rechrtb@gmail.com> | 2022-08-30 15:13:12 +0300 |
---|---|---|
committer | rechrtb <rechrtb@gmail.com> | 2022-08-30 15:19:31 +0300 |
commit | ea2ec7a30cb254d435bcc1912c81ff57991ee650 (patch) | |
tree | 17898fee18f068fc55ac4601fca2001454fc7e74 /src | |
parent | 20f3d6cd93a4dbf22414a317f27f7463b69805cd (diff) |
Increase timeouts for 8266 rtos-based firmware
Diffstat (limited to 'src')
-rw-r--r-- | src/Networking/ESP8266WiFi/WiFiInterface.cpp | 27 | ||||
-rw-r--r-- | src/Networking/ESP8266WiFi/WiFiInterface.h | 2 |
2 files changed, 25 insertions, 4 deletions
diff --git a/src/Networking/ESP8266WiFi/WiFiInterface.cpp b/src/Networking/ESP8266WiFi/WiFiInterface.cpp index 50c50f62..a990e15e 100644 --- a/src/Networking/ESP8266WiFi/WiFiInterface.cpp +++ b/src/Networking/ESP8266WiFi/WiFiInterface.cpp @@ -93,10 +93,9 @@ constexpr SSPChannel ESP_SPI = SSP0; # include "matrix/matrix.h" #endif -const uint32_t WiFiResponseTimeoutMillis = 200; // SPI timeout when when the ESP does not have to write to flash memory -const uint32_t WiFiTransferTimeoutMillis = 60; // Christian measured this at 29 to 31ms when the ESP has to write to flash memory +const uint32_t WiFiResponseTimeoutMillis = 500; // Timeout includes time-intensive flash-access operations; highest measured is 234 ms. const uint32_t WiFiWaitReadyMillis = 100; -const uint32_t WiFiStartupMillis = 300; +const uint32_t WiFiStartupMillis = 8000; const uint32_t WiFiStableMillis = 100; const unsigned int MaxHttpConnections = 4; @@ -577,6 +576,8 @@ void WiFiInterface::Start() noexcept transferAlreadyPendingCount = readyTimeoutCount = responseTimeoutCount = 0; lastTickMillis = millis(); + lastState = 0; + risingEdges = 0; SetState(NetworkState::starting1); } @@ -613,13 +614,31 @@ void WiFiInterface::Spin() noexcept { case NetworkState::starting1: { + const bool currentState = digitalRead(EspDataReadyPin); + if (currentState != lastState) + { + if (currentState) + { + risingEdges++; + } + lastState = currentState; + } + // The ESP toggles CS before it has finished starting up, so don't look at the CS signal too soon const uint32_t now = millis(); - if (now - lastTickMillis >= WiFiStartupMillis) + if (risingEdges >= 2) // the first rising edge is the one coming out of reset { lastTickMillis = now; SetState(NetworkState::starting2); } + else + { + if (now - lastTickMillis >= WiFiStartupMillis) // time wait expired + { + platform.Message(NetworkInfoMessage, "WiFi module disabled - start timed out\n"); + SetState(NetworkState::disabled); + } + } } break; diff --git a/src/Networking/ESP8266WiFi/WiFiInterface.h b/src/Networking/ESP8266WiFi/WiFiInterface.h index 18fac5bc..3512019a 100644 --- a/src/Networking/ESP8266WiFi/WiFiInterface.h +++ b/src/Networking/ESP8266WiFi/WiFiInterface.h @@ -120,6 +120,8 @@ private: Platform& platform; uint32_t lastTickMillis; + bool lastState; + int risingEdges; struct MessageBufferOut { |