From 138851f45f5edda7df1914a330313b18a9d56a7a Mon Sep 17 00:00:00 2001 From: Asbelos Date: Tue, 27 Oct 2020 11:04:51 +0000 Subject: [PATCH] Cleaner purge on ERROR --- WifiInboundHandler.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/WifiInboundHandler.cpp b/WifiInboundHandler.cpp index 81cb3b7..00a682f 100644 --- a/WifiInboundHandler.cpp +++ b/WifiInboundHandler.cpp @@ -85,7 +85,7 @@ WifiInboundHandler::INBOUND_STATE WifiInboundHandler::loop2() { } switch (loopState) { - case ANYTHING: // looking for +IPD, > , busy , n,CONNECTED, n,CLOSED, ERROR + case ANYTHING: // looking for +IPD, > , busy , n,CONNECTED, n,CLOSED, ERROR, SEND OK if (ch == '+') { loopState = IPD; @@ -109,6 +109,11 @@ WifiInboundHandler::INBOUND_STATE WifiInboundHandler::loop2() { loopState=SKIPTOEND; break; } + + if (ch=='S') { // SEND OK probably + loopState=SKIPTOEND; + break; + } if (ch=='b') { // This is a busy indicator... probabaly must restart a CIPSEND pendingCipsend=(clientPendingCIPSEND>=0); @@ -121,6 +126,18 @@ WifiInboundHandler::INBOUND_STATE WifiInboundHandler::loop2() { loopState=GOT_CLIENT_ID; break; } + + if (ch=='E') { // ERROR + if (pendingCipsend) { + // A CIPSEND was errored... just toss it away + if (Diag::WIFI) DIAG(F("Wifi: drop previous CIPSEND\n")); + for (int i=0;i<=currentReplySize;i++) outboundRing->read(); + clientPendingCIPSEND=-1; + pendingCipsend=false; + } + loopState=SKIPTOEND; + break; + } break; @@ -200,7 +217,9 @@ WifiInboundHandler::INBOUND_STATE WifiInboundHandler::loop2() { // CLOSE if (runningClientId==clientPendingCIPSEND) { // clear the outbound for this client - for (int i=0;i<=currentReplySize;i++) outboundRing->read(); + for (int i=0;i<=currentReplySize;i++) outboundRing->read(); + clientPendingCIPSEND=-1; + pendingCipsend=false; } } loopState=SKIPTOEND;