|
@ -225,7 +225,7 @@ public: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* SIM card & Network Operator functions |
|
|
|
|
|
|
|
|
* SIM card functions |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
bool simUnlock(const char *pin) { |
|
|
bool simUnlock(const char *pin) { |
|
@ -253,16 +253,6 @@ public: |
|
|
return res; |
|
|
return res; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int getSignalQuality() { |
|
|
|
|
|
sendAT(GF("+CSQ")); |
|
|
|
|
|
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { |
|
|
|
|
|
return 99; |
|
|
|
|
|
} |
|
|
|
|
|
int res = streamReadUntil(',').toInt(); |
|
|
|
|
|
waitResponse(); |
|
|
|
|
|
return res; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SimStatus getSimStatus(unsigned long timeout = 10000L) { |
|
|
SimStatus getSimStatus(unsigned long timeout = 10000L) { |
|
|
for (unsigned long start = millis(); millis() - start < timeout; ) { |
|
|
for (unsigned long start = millis(); millis() - start < timeout; ) { |
|
|
sendAT(GF("+CPIN?")); |
|
|
sendAT(GF("+CPIN?")); |
|
@ -304,6 +294,20 @@ public: |
|
|
return res; |
|
|
return res; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* Generic network functions |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
int getSignalQuality() { |
|
|
|
|
|
sendAT(GF("+CSQ")); |
|
|
|
|
|
if (waitResponse(GF(GSM_NL "+CSQ:")) != 1) { |
|
|
|
|
|
return 99; |
|
|
|
|
|
} |
|
|
|
|
|
int res = streamReadUntil(',').toInt(); |
|
|
|
|
|
waitResponse(); |
|
|
|
|
|
return res; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
bool waitForNetwork(unsigned long timeout = 60000L) { |
|
|
bool waitForNetwork(unsigned long timeout = 60000L) { |
|
|
for (unsigned long start = millis(); millis() - start < timeout; ) { |
|
|
for (unsigned long start = millis(); millis() - start < timeout; ) { |
|
|
RegStatus s = getRegistrationStatus(); |
|
|
RegStatus s = getRegistrationStatus(); |
|
@ -392,12 +396,6 @@ public: |
|
|
* Messaging functions |
|
|
* Messaging functions |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
void sendUSSD() { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void sendSMS() { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool sendSMS(const String& number, const String& text) { |
|
|
bool sendSMS(const String& number, const String& text) { |
|
|
sendAT(GF("+CMGF=1")); |
|
|
sendAT(GF("+CMGF=1")); |
|
|
waitResponse(); |
|
|
waitResponse(); |
|
@ -413,8 +411,7 @@ public: |
|
|
/* |
|
|
/* |
|
|
* Location functions |
|
|
* Location functions |
|
|
*/ |
|
|
*/ |
|
|
void getLocation() { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* Battery functions |
|
|
* Battery functions |
|
@ -505,8 +502,8 @@ private: |
|
|
|
|
|
|
|
|
// TODO: Optimize this! |
|
|
// TODO: Optimize this! |
|
|
uint8_t waitResponse(uint32_t timeout, String& data, |
|
|
uint8_t waitResponse(uint32_t timeout, String& data, |
|
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR), |
|
|
|
|
|
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL) |
|
|
|
|
|
|
|
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR), |
|
|
|
|
|
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL) |
|
|
{ |
|
|
{ |
|
|
/*String r1s(r1); r1s.trim(); |
|
|
/*String r1s(r1); r1s.trim(); |
|
|
String r2s(r2); r2s.trim(); |
|
|
String r2s(r2); r2s.trim(); |
|
@ -599,15 +596,15 @@ private: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint8_t waitResponse(uint32_t timeout, |
|
|
uint8_t waitResponse(uint32_t timeout, |
|
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR), |
|
|
|
|
|
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL) |
|
|
|
|
|
|
|
|
GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR), |
|
|
|
|
|
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL) |
|
|
{ |
|
|
{ |
|
|
String data; |
|
|
String data; |
|
|
return waitResponse(timeout, data, r1, r2, r3, r4, r5); |
|
|
return waitResponse(timeout, data, r1, r2, r3, r4, r5); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint8_t waitResponse(GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR), |
|
|
uint8_t waitResponse(GsmConstStr r1=GFP(GSM_OK), GsmConstStr r2=GFP(GSM_ERROR), |
|
|
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL) |
|
|
|
|
|
|
|
|
GsmConstStr r3=NULL, GsmConstStr r4=NULL, GsmConstStr r5=NULL) |
|
|
{ |
|
|
{ |
|
|
return waitResponse(1000, r1, r2, r3, r4, r5); |
|
|
return waitResponse(1000, r1, r2, r3, r4, r5); |
|
|
} |
|
|
} |
|
|