From db456b53453b02848fa5ceba7f4191726fa91569 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 20 May 2019 12:38:37 -0400 Subject: [PATCH] Fixes --- library.json | 2 +- library.properties | 2 +- src/TinyGsmClientA6.h | 2 +- src/TinyGsmClientMC60.h | 2 +- src/TinyGsmClientSIM7000.h | 21 ++++++++++++++++----- src/TinyGsmClientSIM800.h | 6 +----- src/TinyGsmCommon.h | 2 +- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/library.json b/library.json index 8428499..53f87cd 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TinyGSM", - "version": "0.7.1", + "version": "0.7.3", "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.", "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M", "authors": diff --git a/library.properties b/library.properties index 6b94145..f7e6ba8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TinyGSM -version=0.7.1 +version=0.7.3 author=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy sentence=A small Arduino library for GPRS modules, that just works. diff --git a/src/TinyGsmClientA6.h b/src/TinyGsmClientA6.h index 3ca5228..7030526 100644 --- a/src/TinyGsmClientA6.h +++ b/src/TinyGsmClientA6.h @@ -71,7 +71,7 @@ public: TINY_GSM_YIELD(); rx.clear(); uint8_t newMux = -1; - sock_connected = at->modemConnect(host, port, &newMux, timeout_s) + sock_connected = at->modemConnect(host, port, &newMux, timeout_s); if (sock_connected) { mux = newMux; at->sockets[mux] = this; diff --git a/src/TinyGsmClientMC60.h b/src/TinyGsmClientMC60.h index cef00d6..e356f47 100644 --- a/src/TinyGsmClientMC60.h +++ b/src/TinyGsmClientMC60.h @@ -374,7 +374,7 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK() } // Check that we have a local IP address - if (localIP() != 0) { + if (localIP() != IPAddress(0,0,0,0)) { return true; } diff --git a/src/TinyGsmClientSIM7000.h b/src/TinyGsmClientSIM7000.h index 5ca038f..e812c26 100644 --- a/src/TinyGsmClientSIM7000.h +++ b/src/TinyGsmClientSIM7000.h @@ -814,26 +814,37 @@ protected: // ^^ Confirmed number of data bytes to be read, which may be less than requested. // 0 indicates that no data can be read. - size_t len_read = 0; for (size_t i=0; irx.put(c); } waitResponse(); DBG("### READ:", len_read, "from", mux); - return len_read; + return TinyGsmMin(len_confirmed, len_requested); + } + + size_t modemGetAvailable(uint8_t mux) { + sendAT(GF("+CIPRXGET=4,"), mux); + size_t result = 0; + if (waitResponse(GF("+CIPRXGET:")) == 1) { + streamSkipUntil(','); // Skip mode 4 + streamSkipUntil(','); // Skip mux + result = stream.readStringUntil('\n').toInt(); + waitResponse(); + } + if (!result) { + sockets[mux]->sock_connected = modemGetConnected(mux); + } + return result; } bool modemGetConnected(uint8_t mux) { diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index e6603ad..6b1face 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -742,26 +742,22 @@ protected: // ^^ Confirmed number of data bytes to be read, which may be less than requested. // 0 indicates that no data can be read. - size_t len_read = 0; for (size_t i=0; irx.put(c); } waitResponse(); DBG("### READ:", len_read, "from", mux); - return len_read; + return TinyGsmMin(len_confirmed, len_requested); } size_t modemGetAvailable(uint8_t mux) { diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index 54408b8..4c65b55 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -10,7 +10,7 @@ #define TinyGsmCommon_h // The current library version number -#define TINYGSM_VERSION "0.7.1" +#define TINYGSM_VERSION "0.7.3" #if defined(SPARK) || defined(PARTICLE) #include "Particle.h"