From 96bbf381ad979814a72c4f5b2e656db71c8bb1c4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 21 May 2019 18:35:37 -0400 Subject: [PATCH] Safer to query the closed sock and get an error --- src/TinyGsmClientSaraR4.h | 6 ++---- src/TinyGsmClientUBLOX.h | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/TinyGsmClientSaraR4.h b/src/TinyGsmClientSaraR4.h index 49eaf2a..cb45109 100644 --- a/src/TinyGsmClientSaraR4.h +++ b/src/TinyGsmClientSaraR4.h @@ -590,8 +590,7 @@ protected: } 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"); size_t result = 0; uint8_t res = waitResponse(GF(GSM_NL "+USORD:")); @@ -610,8 +609,7 @@ protected: } 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"); uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:")); if (res != 1) diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index 0d60e13..53be58d 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -596,8 +596,7 @@ protected: } 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"); size_t result = 0; uint8_t res = waitResponse(GF(GSM_NL "+USORD:")); @@ -616,8 +615,7 @@ protected: } 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"); uint8_t res = waitResponse(GF(GSM_NL "+USOCTL:")); if (res != 1)