Clear buffer on stop(). Fix #119

This commit is contained in:
Volodymyr Shymanskyy
2018-03-14 00:59:02 +02:00
parent e495050a34
commit c8d71b3b8b

View File

@@ -72,6 +72,7 @@ public:
public: public:
virtual int connect(const char *host, uint16_t port) { virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD(); TINY_GSM_YIELD();
rx.clear(); rx.clear();
sock_connected = at->modemConnect(host, port, mux); sock_connected = at->modemConnect(host, port, mux);
@@ -95,6 +96,7 @@ public:
at->sendAT(GF("+CIPCLOSE="), mux); at->sendAT(GF("+CIPCLOSE="), mux);
sock_connected = false; sock_connected = false;
at->waitResponse(); at->waitResponse();
rx.clear();
} }
virtual size_t write(const uint8_t *buf, size_t size) { virtual size_t write(const uint8_t *buf, size_t size) {
@@ -191,6 +193,7 @@ public:
public: public:
virtual int connect(const char *host, uint16_t port) { virtual int connect(const char *host, uint16_t port) {
stop();
TINY_GSM_YIELD(); TINY_GSM_YIELD();
rx.clear(); rx.clear();
sock_connected = at->modemConnect(host, port, mux, true); sock_connected = at->modemConnect(host, port, mux, true);