Check GPRS status on SIM7000
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -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:
|
||||
|
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"
|
||||
|
Reference in New Issue
Block a user