Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Blynk/BlynkProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -247,7 +252,12 @@ bool BlynkProtocol<Transp>::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) {
Expand Down Expand Up @@ -289,7 +299,6 @@ bool BlynkProtocol<Transp>::processInput(void)

if (hdr.length > BLYNK_MAX_READBYTES) {
BLYNK_LOG2(BLYNK_F("Packet too big: "), hdr.length);
// TODO: Flush
internalReconnect();
return true;
}
Expand Down Expand Up @@ -402,7 +411,6 @@ bool BlynkProtocol<Transp>::processInput(void)
#ifdef BLYNK_DEBUG
BLYNK_LOG2(BLYNK_F("Invalid header type: "), hdr.type);
#endif
// TODO: Flush
internalReconnect();
} break;
}
Expand Down