diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-08-31 14:31:00 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-08-31 14:31:00 +0300 |
commit | 9365fa7b739854f06b76c16d5d8dc61c7481950c (patch) | |
tree | cdc11c9e67e57ae0780e3a7b40a7563c14f0b840 /src/Networking | |
parent | 07d6b8078ae0c3ac9fe43a3da2717ed7c20fe69d (diff) | |
parent | d3550b3b618b16f25b70c4a2e9b74cfba4b9c7fe (diff) |
Merge branch '3.4-dev' into 3.4-extruder-only-movement-fix3.4-extruder-only-movement-fix
Diffstat (limited to 'src/Networking')
-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..9e08438b 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(); + lastDataReadyPinState = 0; + risingEdges = 0; SetState(NetworkState::starting1); } @@ -613,13 +614,31 @@ void WiFiInterface::Spin() noexcept { case NetworkState::starting1: { + const bool currentDataReadyPinState = digitalRead(EspDataReadyPin); + if (currentDataReadyPinState != lastDataReadyPinState) + { + if (currentDataReadyPinState && risingEdges < 10) + { + risingEdges++; + } + lastDataReadyPinState = currentDataReadyPinState; + } + // 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..5776f1e6 100644 --- a/src/Networking/ESP8266WiFi/WiFiInterface.h +++ b/src/Networking/ESP8266WiFi/WiFiInterface.h @@ -120,6 +120,8 @@ private: Platform& platform; uint32_t lastTickMillis; + bool lastDataReadyPinState; + uint8_t risingEdges; struct MessageBufferOut { |