Added Network Time Fetching for SimXXX
This commit is contained in:
@@ -126,6 +126,12 @@ void loop() {
|
|||||||
String gsmLoc = modem.getGsmLocation();
|
String gsmLoc = modem.getGsmLocation();
|
||||||
DBG("GSM location:", gsmLoc);
|
DBG("GSM location:", gsmLoc);
|
||||||
|
|
||||||
|
// This is only supported on SIMxxx series
|
||||||
|
String gsmTime = modem.getGSMDateTime(DATE_TIME);
|
||||||
|
DBG("GSM Time:", gsmTime);
|
||||||
|
String gsmDate = modem.getGSMDateTime(DATE_DATE);
|
||||||
|
DBG("GSM Date:", gsmDate);
|
||||||
|
|
||||||
String ussd_balance = modem.sendUSSD("*111#");
|
String ussd_balance = modem.sendUSSD("*111#");
|
||||||
DBG("Balance (USSD):", ussd_balance);
|
DBG("Balance (USSD):", ussd_balance);
|
||||||
|
|
||||||
|
@@ -24,3 +24,6 @@ factoryReset KEYWORD2
|
|||||||
#######################################
|
#######################################
|
||||||
# Literals (LITERAL1)
|
# Literals (LITERAL1)
|
||||||
#######################################
|
#######################################
|
||||||
|
DATE_FULL LITERAL1
|
||||||
|
DATE_TIME LITERAL1
|
||||||
|
DATE_DATE LITERAL1
|
||||||
|
@@ -39,6 +39,11 @@ enum RegStatus {
|
|||||||
REG_UNKNOWN = 4,
|
REG_UNKNOWN = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum DateTime {
|
||||||
|
DATE_FULL = 0,
|
||||||
|
DATE_TIME = 1,
|
||||||
|
DATE_DATE = 2
|
||||||
|
};
|
||||||
|
|
||||||
class TinyGsmSim800
|
class TinyGsmSim800
|
||||||
{
|
{
|
||||||
@@ -307,6 +312,13 @@ public:
|
|||||||
if (!testAT()) {
|
if (!testAT()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//Enable Local Time Stamp for getting network time
|
||||||
|
sendAT(GF("+CLTS=1"));
|
||||||
|
if (waitResponse(10000L) != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
sendAT(GF("&W"));
|
||||||
|
waitResponse();
|
||||||
sendAT(GF("+CFUN=0"));
|
sendAT(GF("+CFUN=0"));
|
||||||
if (waitResponse(10000L) != 1) {
|
if (waitResponse(10000L) != 1) {
|
||||||
return false;
|
return false;
|
||||||
@@ -719,6 +731,32 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Time functions
|
||||||
|
*/
|
||||||
|
String getGSMDateTime(DateTime format) {
|
||||||
|
sendAT(GF("+CCLK?"));
|
||||||
|
if (waitResponse(2000L, GF(GSM_NL "+CCLK: \"")) != 1) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String res;
|
||||||
|
|
||||||
|
switch(format) {
|
||||||
|
case DATE_FULL:
|
||||||
|
res = stream.readStringUntil('"');
|
||||||
|
break;
|
||||||
|
case DATE_TIME:
|
||||||
|
streamSkipUntil(',');
|
||||||
|
res = stream.readStringUntil('"');
|
||||||
|
break;
|
||||||
|
case DATE_DATE:
|
||||||
|
res = stream.readStringUntil(',');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Battery functions
|
* Battery functions
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user