From eb9358f44057d912cbab4894196997d265ab5110 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 14 Apr 2020 21:38:15 -0400 Subject: [PATCH] Check GPRS status on SIM7000 Signed-off-by: Sara Damiano --- .github/ISSUE_TEMPLATE.md | 2 +- README.md | 2 +- library.json | 2 +- library.properties | 2 +- src/TinyGsmClientSIM7000.h | 10 +++++++++- src/TinyGsmClientSaraR4.h | 18 ++++-------------- src/TinyGsmCommon.h | 2 +- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 8c31c06..98b342b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -22,7 +22,7 @@ with your board before submitting any issues. Main processor board: Modem: -TinyGSM version: +TinyGSM version: Code: ### Scenario, steps to reproduce diff --git a/README.md b/README.md index 50528a3..de71408 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Watch this repo for new updates! And of course, contributions are welcome ;) **Location** - GPS/GNSS - SIM808, SIM7000, SIM7500/7600/7800, BG96, u-blox - - NOTE: u-blox chips do NOT have embedded GPS - this function only works if a secondary GPS is connected to primary cellular chip over I2C + - NOTE: u-blox chips do _NOT_ have embedded GPS - this function only works if a secondary GPS is connected to primary cellular chip over I2C - GSM location service - SIM800, SIM7000, Quectel, u-blox diff --git a/library.json b/library.json index 825befa..d9f01fe 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TinyGSM", - "version": "0.10.1", + "version": "0.10.2", "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 3d0e6a5..8b1fd67 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TinyGSM -version=0.10.1 +version=0.10.2 author=Volodymyr Shymanskyy maintainer=Volodymyr Shymanskyy sentence=A small Arduino library for GPRS modules, that just works. diff --git a/src/TinyGsmClientSIM7000.h b/src/TinyGsmClientSIM7000.h index 081eb93..a85ca48 100644 --- a/src/TinyGsmClientSIM7000.h +++ b/src/TinyGsmClientSIM7000.h @@ -239,7 +239,15 @@ class TinyGsmSim7000 : public TinyGsmModem, */ public: RegStatus getRegistrationStatus() { - return (RegStatus)getRegistrationStatusXREG("CEREG"); + RegStatus epsStatus = (RegStatus)getRegistrationStatusXREG("CEREG"); + // If we're connected on EPS, great! + if (epsStatus == REG_OK_HOME || epsStatus == REG_OK_ROAMING) { + return epsStatus; + } else { + // Otherwise, check GPRS network status + // We could be using GPRS fall-back or the board could be being moody + return (RegStatus)getRegistrationStatusXREG("CGREG"); + } } protected: diff --git a/src/TinyGsmClientSaraR4.h b/src/TinyGsmClientSaraR4.h index 945968a..0ab9054 100644 --- a/src/TinyGsmClientSaraR4.h +++ b/src/TinyGsmClientSaraR4.h @@ -317,24 +317,14 @@ class TinyGsmSaraR4 : public TinyGsmModem, public: RegStatus getRegistrationStatus() { // Check first for EPS registration - sendAT(GF("+CEREG?")); - if (waitResponse(GF(GSM_NL "+CEREG:")) != 1) { return REG_UNKNOWN; } - streamSkipUntil(','); /* Skip format (0) */ - int status = streamGetIntBefore('\n'); - waitResponse(); + RegStatus epsStatus = (RegStatus)getRegistrationStatusXREG("CEREG"); // If we're connected on EPS, great! - if ((RegStatus)status == REG_OK_HOME || - (RegStatus)status == REG_OK_ROAMING) { - return (RegStatus)status; + if (epsStatus == REG_OK_HOME || epsStatus == REG_OK_ROAMING) { + return epsStatus; } else { // Otherwise, check generic network status - sendAT(GF("+CREG?")); - if (waitResponse(GF(GSM_NL "+CREG:")) != 1) { return REG_UNKNOWN; } - streamSkipUntil(','); /* Skip format (0) */ - status = streamGetIntBefore('\n'); - waitResponse(); - return (RegStatus)status; + return (RegStatus)getRegistrationStatusXREG("CREG"); } } diff --git a/src/TinyGsmCommon.h b/src/TinyGsmCommon.h index 7249b01..00679f1 100644 --- a/src/TinyGsmCommon.h +++ b/src/TinyGsmCommon.h @@ -10,7 +10,7 @@ #define SRC_TINYGSMCOMMON_H_ // The current library version number -#define TINYGSM_VERSION "0.10.1" +#define TINYGSM_VERSION "0.10.2" #if defined(SPARK) || defined(PARTICLE) #include "Particle.h"