Browse Source

Safer to query the closed sock and get an error

v_master
Sara Damiano 5 years ago
parent
commit
96bbf381ad
2 changed files with 4 additions and 8 deletions
  1. +2
    -4
      src/TinyGsmClientSaraR4.h
  2. +2
    -4
      src/TinyGsmClientUBLOX.h

+ 2
- 4
src/TinyGsmClientSaraR4.h View File

@ -590,8 +590,7 @@ protected:
} }
size_t modemGetAvailable(uint8_t mux) { size_t modemGetAvailable(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return 0;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USORD="), mux, ",0"); sendAT(GF("+USORD="), mux, ",0");
size_t result = 0; size_t result = 0;
uint8_t res = waitResponse(GF(GSM_NL "+USORD:")); uint8_t res = waitResponse(GF(GSM_NL "+USORD:"));
@ -610,8 +609,7 @@ protected:
} }
bool modemGetConnected(uint8_t mux) { bool modemGetConnected(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return false;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USOCTL="), mux, ",10"); sendAT(GF("+USOCTL="), mux, ",10");
uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:")); uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:"));
if (res != 1) if (res != 1)


+ 2
- 4
src/TinyGsmClientUBLOX.h View File

@ -596,8 +596,7 @@ protected:
} }
size_t modemGetAvailable(uint8_t mux) { size_t modemGetAvailable(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return 0;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USORD="), mux, ",0"); sendAT(GF("+USORD="), mux, ",0");
size_t result = 0; size_t result = 0;
uint8_t res = waitResponse(GF(GSM_NL "+USORD:")); uint8_t res = waitResponse(GF(GSM_NL "+USORD:"));
@ -616,8 +615,7 @@ protected:
} }
bool modemGetConnected(uint8_t mux) { bool modemGetConnected(uint8_t mux) {
// Querying a closed socket gives an error "operation not allowed"
if (!sockets[mux]->sock_connected) return false;
// NOTE: Querying a closed socket gives an error "operation not allowed"
sendAT(GF("+USOCTL="), mux, ",10"); sendAT(GF("+USOCTL="), mux, ",10");
uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:")); uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:"));
if (res != 1) if (res != 1)


Loading…
Cancel
Save