diff --git a/library.json b/library.json index 96291af..49a5385 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TinyGSM", - "version": "0.7.7", + "version": "0.7.9", "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 14c6576..df969ab 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TinyGSM -version=0.7.7 +version=0.7.9 author=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy sentence=A small Arduino library for GPRS modules, that just works. diff --git a/src/TinyGsmClientBG96.h b/src/TinyGsmClientBG96.h index 132b993..e1eb09c 100644 --- a/src/TinyGsmClientBG96.h +++ b/src/TinyGsmClientBG96.h @@ -552,6 +552,7 @@ protected: } waitResponse(); DBG("### READ:", len, "from", mux); + sockets[mux]->sock_available = modemGetAvailable(mux); return len; } diff --git a/src/TinyGsmClientM95.h b/src/TinyGsmClientM95.h index 3921fa7..346d04d 100644 --- a/src/TinyGsmClientM95.h +++ b/src/TinyGsmClientM95.h @@ -621,8 +621,6 @@ protected: streamSkipUntil(','); // skip port streamSkipUntil(','); // skip connection type (TCP/UDP) size_t len = stream.readStringUntil('\n').toInt(); // read length - sockets[mux]->sock_available = len; - for (size_t i=0; isock_available--; diff --git a/src/TinyGsmClientMC60.h b/src/TinyGsmClientMC60.h index 667d6eb..b327fd0 100644 --- a/src/TinyGsmClientMC60.h +++ b/src/TinyGsmClientMC60.h @@ -628,8 +628,6 @@ protected: streamSkipUntil(','); // skip port streamSkipUntil(','); // skip connection type (TCP/UDP) size_t len = stream.readStringUntil('\n').toInt(); // read length - sockets[mux]->sock_available = len; - for (size_t i=0; isock_available--; diff --git a/src/TinyGsmClientSIM7000.h b/src/TinyGsmClientSIM7000.h index 458a05b..c8e04ef 100644 --- a/src/TinyGsmClientSIM7000.h +++ b/src/TinyGsmClientSIM7000.h @@ -181,7 +181,20 @@ public: } String getModemName() { - return "SIMCom SIM7000"; + String name = "SIMCom SIM7000"; + + sendAT(GF("+GMM")); + String res2; + if (waitResponse(1000L, res2) != 1) { + return name; + } + res2.replace(GSM_NL "OK" GSM_NL, ""); + res2.replace("_", " "); + res2.trim(); + + name = res2; + DBG("### Modem:", name); + return name; } TINY_GSM_MODEM_SET_BAUD_IPR() diff --git a/src/TinyGsmClientSIM800.h b/src/TinyGsmClientSIM800.h index f2030dd..365f4ee 100644 --- a/src/TinyGsmClientSIM800.h +++ b/src/TinyGsmClientSIM800.h @@ -184,16 +184,29 @@ public: } String getModemName() { + String name = ""; #if defined(TINY_GSM_MODEM_SIM800) - return "SIMCom SIM800"; + name = "SIMCom SIM800"; #elif defined(TINY_GSM_MODEM_SIM808) - return "SIMCom SIM808"; + name = "SIMCom SIM808"; #elif defined(TINY_GSM_MODEM_SIM868) - return "SIMCom SIM868"; + name = "SIMCom SIM868"; #elif defined(TINY_GSM_MODEM_SIM900) - return "SIMCom SIM900"; + name = "SIMCom SIM900"; #endif - return "SIMCom SIM800"; + + sendAT(GF("+GMM")); + String res2; + if (waitResponse(1000L, res2) != 1) { + return name; + } + res2.replace(GSM_NL "OK" GSM_NL, ""); + res2.replace("_", " "); + res2.trim(); + + name = res2; + DBG("### Modem:", name); + return name; } TINY_GSM_MODEM_SET_BAUD_IPR() @@ -269,7 +282,7 @@ TINY_GSM_MODEM_GET_INFO_ATI() bool poweroff() { sendAT(GF("+CPOWD=1")); - return waitResponse(GF("NORMAL POWER DOWN")) == 1; + return waitResponse(10000L, GF("NORMAL POWER DOWN")) == 1; } bool radioOff() { diff --git a/src/TinyGsmClientSaraR4.h b/src/TinyGsmClientSaraR4.h index a4763cd..42bc8ea 100644 --- a/src/TinyGsmClientSaraR4.h +++ b/src/TinyGsmClientSaraR4.h @@ -100,7 +100,7 @@ TINY_GSM_CLIENT_CONNECT_OVERLOADS() // that it wants from the socket even if it was closed externally. rx.clear(); at->maintain(); - while (sock_available > 0) { + while (sock_connected && sock_available > 0) { at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux); rx.clear(); at->maintain(); @@ -613,6 +613,7 @@ protected: streamSkipUntil('\"'); waitResponse(); DBG("### READ:", len, "from", mux); + sockets[mux]->sock_available = modemGetAvailable(mux); return len; } @@ -628,8 +629,10 @@ protected: result = stream.readStringUntil('\n').toInt(); // if (result) DBG("### DATA AVAILABLE:", result, "on", mux); waitResponse(); + } else if (res == 3) { + streamSkipUntil('\n'); // Skip the error text } - if (!result && res != 2 && res != 3) { // Don't check modemGetConnected after an error + if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } return result; diff --git a/src/TinyGsmClientSequansMonarch.h b/src/TinyGsmClientSequansMonarch.h index 1c145e1..8599c5a 100644 --- a/src/TinyGsmClientSequansMonarch.h +++ b/src/TinyGsmClientSequansMonarch.h @@ -624,7 +624,7 @@ protected: } DBG("### Read:", len, "from", mux); waitResponse(); - // sockets[mux % TINY_GSM_MUX_COUNT]->sock_available = modemGetAvailable(mux); + sockets[mux % TINY_GSM_MUX_COUNT]->sock_available = modemGetAvailable(mux); return len; } diff --git a/src/TinyGsmClientUBLOX.h b/src/TinyGsmClientUBLOX.h index b232db3..180615e 100644 --- a/src/TinyGsmClientUBLOX.h +++ b/src/TinyGsmClientUBLOX.h @@ -100,7 +100,7 @@ TINY_GSM_CLIENT_CONNECT_OVERLOADS() // that it wants from the socket even if it was closed externally. rx.clear(); at->maintain(); - while (sock_available > 0) { + while (sock_connected && sock_available > 0) { at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux); rx.clear(); at->maintain(); @@ -501,8 +501,10 @@ TINY_GSM_MODEM_GET_GPRS_IP_CONNECTED() } int res = stream.readStringUntil(',').toInt(); + int8_t percent = res*20; // return is 0-5 + // Wait for final OK waitResponse(); - return res; + return percent; } uint8_t getBattChargeState() TINY_GSM_ATTR_NOT_AVAILABLE; @@ -601,6 +603,7 @@ protected: streamSkipUntil('\"'); waitResponse(); DBG("### READ:", len, "from", mux); + sockets[mux]->sock_available = modemGetAvailable(mux); return len; } @@ -616,8 +619,10 @@ protected: result = stream.readStringUntil('\n').toInt(); // if (result) DBG("### DATA AVAILABLE:", result, "on", mux); waitResponse(); + } else if (res == 3) { + streamSkipUntil('\n'); // Skip the error text } - if (!result && res != 2 && res != 3) { // Don't check modemGetConnected after an error + if (!result) { sockets[mux]->sock_connected = modemGetConnected(mux); } return result; diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index 3c66d9c..7b87633 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.7" +#define TINYGSM_VERSION "0.7.9" #if defined(SPARK) || defined(PARTICLE) #include "Particle.h"