Browse Source

Removed recursive calls to maitain (shouldn't I have leared)

v_master
Sara Damiano 5 years ago
parent
commit
99a5b3938c
6 changed files with 21 additions and 39 deletions
  1. +0
    -4
      src/TinyGsmClientBG96.h
  2. +0
    -4
      src/TinyGsmClientM95.h
  3. +0
    -4
      src/TinyGsmClientMC60.h
  4. +0
    -4
      src/TinyGsmClientSIM7000.h
  5. +0
    -4
      src/TinyGsmClientSIM800.h
  6. +21
    -19
      src/TinyGsmClientUBLOX.h

+ 0
- 4
src/TinyGsmClientBG96.h View File

@ -656,7 +656,6 @@ protected:
return 0; return 0;
} }
// TODO: Wait for ACK? AT+QISEND=id,0 // TODO: Wait for ACK? AT+QISEND=id,0
maintain(); // look for a very quick response from the remote
return len; return len;
} }
@ -675,7 +674,6 @@ protected:
} }
waitResponse(); waitResponse();
DBG("### READ:", len, "from", mux); DBG("### READ:", len, "from", mux);
maintain(); // Listen for a close or other URC
return len; return len;
} }
@ -692,7 +690,6 @@ protected:
if (!result) { if (!result) {
sockets[mux]->sock_connected = modemGetConnected(mux); sockets[mux]->sock_connected = modemGetConnected(mux);
} }
maintain(); // Listen for a close or other URC
return result; return result;
} }
@ -711,7 +708,6 @@ protected:
int res = stream.readStringUntil(',').toInt(); // socket state int res = stream.readStringUntil(',').toInt(); // socket state
waitResponse(); waitResponse();
maintain(); // Listen for a close or other URC
// 0 Initial, 1 Opening, 2 Connected, 3 Listening, 4 Closing // 0 Initial, 1 Opening, 2 Connected, 3 Listening, 4 Closing
return 2 == res; return 2 == res;


+ 0
- 4
src/TinyGsmClientM95.h View File

@ -708,7 +708,6 @@ protected:
} }
} }
waitResponse(5000L); waitResponse(5000L);
maintain(); // look for a very quick response from the remote
// streamSkipUntil(','); // Skip mux // streamSkipUntil(','); // Skip mux
// return stream.readStringUntil('\n').toInt(); // return stream.readStringUntil('\n').toInt();
@ -730,7 +729,6 @@ protected:
} }
waitResponse(); waitResponse();
DBG("### READ:", len, "from", mux); DBG("### READ:", len, "from", mux);
maintain(); // Listen for a close or other URC
return len; return len;
} }
@ -747,7 +745,6 @@ protected:
if (!result) { if (!result) {
sockets[mux]->sock_connected = modemGetConnected(mux); sockets[mux]->sock_connected = modemGetConnected(mux);
} }
maintain(); // Listen for a close or other URC
return result; return result;
} }
@ -766,7 +763,6 @@ protected:
int res = stream.readStringUntil(',').toInt(); // socket state int res = stream.readStringUntil(',').toInt(); // socket state
waitResponse(); waitResponse();
maintain(); // Listen for a close or other URC
// 0 Initial, 1 Opening, 2 Connected, 3 Listening, 4 Closing // 0 Initial, 1 Opening, 2 Connected, 3 Listening, 4 Closing
return 2 == res; return 2 == res;


+ 0
- 4
src/TinyGsmClientMC60.h View File

@ -740,7 +740,6 @@ protected:
// streamSkipUntil(','); // Skip mux // streamSkipUntil(','); // Skip mux
// return stream.readStringUntil('\n').toInt(); // return stream.readStringUntil('\n').toInt();
maintain(); // look for a very quick response from the remote
return len; // TODO return len; // TODO
} }
@ -759,7 +758,6 @@ protected:
} }
waitResponse(); waitResponse();
DBG("### READ:", len, "from", mux); DBG("### READ:", len, "from", mux);
maintain(); // Listen for a close or other URC
return len; return len;
} }
@ -776,7 +774,6 @@ protected:
if (!result) { if (!result) {
sockets[mux]->sock_connected = modemGetConnected(mux); sockets[mux]->sock_connected = modemGetConnected(mux);
} }
maintain(); // Listen for a close or other URC
return result; return result;
} }
@ -795,7 +792,6 @@ protected:
int res = stream.readStringUntil(',').toInt(); // socket state int res = stream.readStringUntil(',').toInt(); // socket state
waitResponse(); waitResponse();
maintain(); // Listen for a close or other URC
// 0 Initial, 1 Opening, 2 Connected, 3 Listening, 4 Closing // 0 Initial, 1 Opening, 2 Connected, 3 Listening, 4 Closing
return 2 == res; return 2 == res;


+ 0
- 4
src/TinyGsmClientSIM7000.h View File

@ -960,7 +960,6 @@ protected:
return 0; return 0;
} }
streamSkipUntil(','); // Skip mux streamSkipUntil(','); // Skip mux
maintain(); // look for a very quick response from the remote
return stream.readStringUntil('\n').toInt(); return stream.readStringUntil('\n').toInt();
} }
@ -1003,7 +1002,6 @@ protected:
} }
waitResponse(); waitResponse();
DBG("### READ:", len_confirmed, "from", mux); DBG("### READ:", len_confirmed, "from", mux);
maintain(); // Listen for a close or other URC
return len_confirmed; return len_confirmed;
} }
@ -1019,7 +1017,6 @@ protected:
if (!result) { if (!result) {
sockets[mux]->sock_connected = modemGetConnected(mux); sockets[mux]->sock_connected = modemGetConnected(mux);
} }
maintain(); // Listen for a close or other URC
return result; return result;
} }
@ -1027,7 +1024,6 @@ protected:
sendAT(GF("+CIPSTATUS="), mux); sendAT(GF("+CIPSTATUS="), mux);
int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\"")); int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
waitResponse(); waitResponse();
maintain(); // Listen for a close or other URC
return 1 == res; return 1 == res;
} }


+ 0
- 4
src/TinyGsmClientSIM800.h View File

@ -883,7 +883,6 @@ protected:
return 0; return 0;
} }
streamSkipUntil(','); // Skip mux streamSkipUntil(','); // Skip mux
maintain(); // look for a very quick response from the remote
return stream.readStringUntil('\n').toInt(); return stream.readStringUntil('\n').toInt();
} }
@ -926,7 +925,6 @@ protected:
} }
waitResponse(); waitResponse();
DBG("### READ:", len_confirmed, "from", mux); DBG("### READ:", len_confirmed, "from", mux);
maintain(); // Listen for a close or other URC
return len_confirmed; return len_confirmed;
} }
@ -942,7 +940,6 @@ protected:
if (!result) { if (!result) {
sockets[mux]->sock_connected = modemGetConnected(mux); sockets[mux]->sock_connected = modemGetConnected(mux);
} }
maintain(); // Listen for a close or other URC
return result; return result;
} }
@ -950,7 +947,6 @@ protected:
sendAT(GF("+CIPSTATUS="), mux); sendAT(GF("+CIPSTATUS="), mux);
int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\"")); int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\""));
waitResponse(); waitResponse();
maintain(); // Listen for a close or other URC
return 1 == res; return 1 == res;
} }


+ 21
- 19
src/TinyGsmClientUBLOX.h View File

@ -62,8 +62,8 @@ public:
sock_connected = false; sock_connected = false;
got_data = false; got_data = false;
// Don't attach the socket here because we won't know the mux channel number
// until the u-blox assigns it upon opening the socket
at->sockets[mux] = this;
return true; return true;
} }
@ -88,11 +88,14 @@ public:
} }
TINY_GSM_YIELD(); TINY_GSM_YIELD();
rx.clear(); rx.clear();
// sock_connected = at->modemConnect(host, port, mux);
uint8_t oldMux = mux;
sock_connected = at->modemConnect(host, port, &mux); sock_connected = at->modemConnect(host, port, &mux);
if (mux != oldMux) {
DBG("WARNING: Mux number changed from", oldMux, "to", mux);
at->sockets[oldMux] = NULL;
}
at->sockets[mux] = this; at->sockets[mux] = this;
// Attach the socket after attempting connection because u-blox will assign
// whatever mux number is next regardless of the number requested.
at->maintain(); at->maintain();
return sock_connected; return sock_connected;
} }
@ -276,15 +279,8 @@ public:
#endif #endif
waitResponse(); waitResponse();
String name = getModemName();
DBG(GF("### Modem:"), name);
if (name.startsWith("u-blox SARA-R4") or name.startsWith("u-blox SARA-N4")) {
DBG(GF("### This is an LTE-M modem!"), name);
isCatM = true;
}
else if (name.startsWith("u-blox SARA-N2")) {
DBG(GF("### SARA N2 NB-IoT modems not supported!"), name);
}
getModemName();
int ret = getSimStatus(); int ret = getSimStatus();
// if the sim isn't ready and a pin has been provided, try to unlock the sim // if the sim isn't ready and a pin has been provided, try to unlock the sim
if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) { if (ret != SIM_READY && pin != NULL && strlen(pin) > 0) {
@ -317,8 +313,18 @@ public:
} }
res2.replace(GSM_NL "OK" GSM_NL, ""); res2.replace(GSM_NL "OK" GSM_NL, "");
res2.trim(); res2.trim();
String name = res1 + String(' ') + res2;
DBG("### Modem:", name);
if (name.startsWith("u-blox SARA-R4") or name.startsWith("u-blox SARA-N4")) {
DBG("### This is an LTE-M modem!");
isCatM = true;
}
else if (name.startsWith("u-blox SARA-N2")) {
DBG("### SARA N2 NB-IoT modems not supported!");
}
return res1 + String(' ') + res2;
return name;
} }
void setBaud(unsigned long baud) { void setBaud(unsigned long baud) {
@ -835,7 +841,6 @@ protected:
streamSkipUntil(','); // Skip mux streamSkipUntil(','); // Skip mux
int sent = stream.readStringUntil('\n').toInt(); int sent = stream.readStringUntil('\n').toInt();
waitResponse(); // sends back OK after the confirmation of number sent waitResponse(); // sends back OK after the confirmation of number sent
maintain(); // look for a very quick response from the remote
return sent; return sent;
} }
@ -857,7 +862,6 @@ protected:
streamSkipUntil('\"'); streamSkipUntil('\"');
waitResponse(); waitResponse();
DBG("### READ:", len, "from", mux); DBG("### READ:", len, "from", mux);
maintain(); // Listen for a close or other URC
return len; return len;
} }
@ -876,7 +880,6 @@ protected:
if (!result && res != 2 && res != 3) { // Don't check modemGetConnected after an error if (!result && res != 2 && res != 3) { // Don't check modemGetConnected after an error
sockets[mux]->sock_connected = modemGetConnected(mux); sockets[mux]->sock_connected = modemGetConnected(mux);
} }
maintain(); // Listen for a close or other URC
return result; return result;
} }
@ -902,7 +905,6 @@ protected:
// 9: the socket is in LAST_ACK status // 9: the socket is in LAST_ACK status
// 10: the socket is in TIME_WAIT status // 10: the socket is in TIME_WAIT status
waitResponse(); waitResponse();
maintain(); // Listen for a close or other URC
return (result != 0); return (result != 0);
} }


Loading…
Cancel
Save