Check GPRS status on SIM7000

Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
Sara Damiano
2020-04-14 21:38:15 -04:00
parent 590736c973
commit eb9358f440
7 changed files with 18 additions and 20 deletions

View File

@@ -239,7 +239,15 @@ class TinyGsmSim7000 : public TinyGsmModem<TinyGsmSim7000>,
*/
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:

View File

@@ -317,24 +317,14 @@ class TinyGsmSaraR4 : public TinyGsmModem<TinyGsmSaraR4>,
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");
}
}

View File

@@ -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"