diff --git a/src/Blynk/BlynkProtocol.h b/src/Blynk/BlynkProtocol.h index 34373622..3ecb7ebc 100644 --- a/src/Blynk/BlynkProtocol.h +++ b/src/Blynk/BlynkProtocol.h @@ -105,9 +105,14 @@ class BlynkProtocol private: void internalReconnect() { +#ifdef BLYNK_USE_DIRECT_CONNECT + conn.connect(); // flushing the buffer to resync +#else + // TODO flush state = CONNECTING; conn.disconnect(); BlynkOnDisconnected(); +#endif } int readHeader(BlynkHeader& hdr); @@ -247,7 +252,12 @@ bool BlynkProtocol::processInput(void) #ifdef BLYNK_DEBUG BLYNK_LOG2(BLYNK_F("Bad hdr len: "), ret); #endif +#ifdef BLYNK_USE_DIRECT_CONNECT + internalReconnect(); + return true; +#else return false; +#endif } if (hdr.type == BLYNK_CMD_RESPONSE) { @@ -289,7 +299,6 @@ bool BlynkProtocol::processInput(void) if (hdr.length > BLYNK_MAX_READBYTES) { BLYNK_LOG2(BLYNK_F("Packet too big: "), hdr.length); - // TODO: Flush internalReconnect(); return true; } @@ -402,7 +411,6 @@ bool BlynkProtocol::processInput(void) #ifdef BLYNK_DEBUG BLYNK_LOG2(BLYNK_F("Invalid header type: "), hdr.type); #endif - // TODO: Flush internalReconnect(); } break; }