TinyGSM
TinyGSM copied to clipboard
[SIM7600] getSimStatusImpl() locking for multiple seconds
Hello Everyone,
Seems like "getSimStatus()" (related to "getSimStatusImpl()" in file "TinyGsmGPRS.tpp") is locking code for some delay (timeout_ms = 10000L).
Is there any way of avoiding such a time lock ?
Does command "getSimStatus()" actually takes time to complete ?
Attached related code from file "TinyGsmGPRS.tpp"
SimStatus getSimStatusImpl(uint32_t timeout_ms = 10000L) {
for (uint32_t start = millis(); millis() - start < timeout_ms;) {
thisModem().sendAT(GF("+CPIN?"));
if (thisModem().waitResponse(GF("+CPIN:")) != 1) {
delay(1000);
continue;
}
int8_t status =
thisModem().waitResponse(GF("READY"), GF("SIM PIN"), GF("SIM PUK"),
GF("NOT INSERTED"), GF("NOT READY"));
thisModem().waitResponse();
switch (status) {
case 2:
case 3: return SIM_LOCKED;
case 1: return SIM_READY;
default: return SIM_ERROR;
}
}
return SIM_ERROR;
}
Thanks
Depends if there's a working sim inserted at power on. No sim, the modem takes a while to respond. With sim, pretty much straight away.
modem.init() or modem.restart() won't succeed without sim inserted. Both methods only takes a few seconds to complete if sim is inserted on SIM7600 and SIM7000. Call that first then if successful call modem.getSimStatus() if you need it.