Browse Source

Fix connect() returning false positive result.

v_master
Volodymyr Shymanskyy 7 years ago
parent
commit
7052185f88
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      TinyGsmClientA6.h

+ 6
- 3
TinyGsmClientA6.h View File

@ -107,6 +107,7 @@ public:
} }
virtual int available() { virtual int available() {
//DBG("available?");
TINY_GSM_YIELD(); TINY_GSM_YIELD();
if (!rx.size() && sock_connected) { if (!rx.size() && sock_connected) {
at->maintain(); at->maintain();
@ -115,6 +116,7 @@ public:
} }
virtual int read(uint8_t *buf, size_t size) { virtual int read(uint8_t *buf, size_t size) {
//DBG("read:", size);
TINY_GSM_YIELD(); TINY_GSM_YIELD();
size_t cnt = 0; size_t cnt = 0;
while (cnt < size) { while (cnt < size) {
@ -432,11 +434,11 @@ public:
private: private:
int modemConnect(const char* host, uint16_t port, uint8_t* mux) {
bool modemConnect(const char* host, uint16_t port, uint8_t* mux) {
sendAT(GF("+CIPSTART="), GF("\"TCP"), GF("\",\""), host, GF("\","), port); sendAT(GF("+CIPSTART="), GF("\"TCP"), GF("\",\""), host, GF("\","), port);
if (waitResponse(75000L, GF(GSM_NL "+CIPNUM:")) != 1) { if (waitResponse(75000L, GF(GSM_NL "+CIPNUM:")) != 1) {
return -1;
return false;
} }
int newMux = stream.readStringUntil('\n').toInt(); int newMux = stream.readStringUntil('\n').toInt();
@ -445,7 +447,7 @@ private:
GF("CONNECT FAIL" GSM_NL), GF("CONNECT FAIL" GSM_NL),
GF("ALREADY CONNECT" GSM_NL)); GF("ALREADY CONNECT" GSM_NL));
if (waitResponse() != 1) { if (waitResponse() != 1) {
return -1;
return false;
} }
*mux = newMux; *mux = newMux;
@ -556,6 +558,7 @@ public:
int mux = stream.readStringUntil('\n').toInt(); int mux = stream.readStringUntil('\n').toInt();
sockets[mux]->sock_connected = false; sockets[mux]->sock_connected = false;
data = ""; data = "";
DBG("### Closed: ", mux);
} }
} }
} while (millis() - startMillis < timeout); } while (millis() - startMillis < timeout);


Loading…
Cancel
Save