Reorder some functions

This commit is contained in:
Sara Damiano
2020-02-11 11:08:03 -05:00
parent 06c31aa856
commit 41531c339b
14 changed files with 317 additions and 283 deletions

View File

@@ -226,33 +226,6 @@ class TinyGsmMC60
return waitResponse() == 1;
}
/*
* SIM card functions
*/
protected:
SimStatus getSimStatusImpl(uint32_t timeout_ms = 10000L) {
for (uint32_t start = millis(); millis() - start < timeout_ms;) {
sendAT(GF("+CPIN?"));
if (waitResponse(GF(GSM_NL "+CPIN:")) != 1) {
delay(1000);
continue;
}
int status = waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"),
GF("NOT INSERTED"), GF("PH_SIM PIN"),
GF("PH_SIM PUK"));
waitResponse();
switch (status) {
case 2:
case 3: return SIM_LOCKED;
case 5:
case 6: return SIM_ANTITHEFT_LOCKED;
case 1: return SIM_READY;
default: return SIM_ERROR;
}
}
return SIM_ERROR;
}
/*
* Generic network functions
*/
@@ -267,6 +240,18 @@ class TinyGsmMC60
return (s == REG_OK_HOME || s == REG_OK_ROAMING);
}
/*
* IP Address functions
*/
protected:
String getLocalIPImpl() {
sendAT(GF("+QILOCIP"));
streamSkipUntil('\n');
String res = stream.readStringUntil('\n');
res.trim();
return res;
}
/*
* GPRS functions
*/
@@ -326,15 +311,34 @@ class TinyGsmMC60
}
/*
* IP Address functions
* SIM card functions
*/
protected:
String getLocalIPImpl() {
sendAT(GF("+QILOCIP"));
streamSkipUntil('\n');
String res = stream.readStringUntil('\n');
res.trim();
return res;
SimStatus getSimStatusImpl(uint32_t timeout_ms = 10000L) {
for (uint32_t start = millis(); millis() - start < timeout_ms;) {
sendAT(GF("+CPIN?"));
if (waitResponse(GF(GSM_NL "+CPIN:")) != 1) {
delay(1000);
continue;
}
int status =
waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"),
GF("NOT INSERTED"), GF("PH_SIM PIN"), GF("PH_SIM PUK"));
waitResponse();
switch (status) {
case 2:
case 3:
return SIM_LOCKED;
case 5:
case 6:
return SIM_ANTITHEFT_LOCKED;
case 1:
return SIM_READY;
default:
return SIM_ERROR;
}
}
return SIM_ERROR;
}
/*