Closed salvq closed 4 years ago
Hello, similar situation right after transmission SIM card is not present. After board reset communication continues...is it this infinity loop correct way to handle the situation ?
void onNetworkDisconnect(void *_arg) {
Serial.println(">>>> DISCONNECTED from network");
}
08:19:15.795 -> Publishing message, timestamp: 08:19:15,CET
08:19:24.364 -> >>>> DISCONNECTED from network
08:19:25.049 -> Disconnected from Cellular Network
08:19:25.049 -> Attempting reconnection
08:19:25.049 -> Attempting reconnection
08:19:40.696 -> SIM not present or wrong PIN
I took out the PIN to eliminate other possibility but same behavior, time to time I am getting SIM not present or wrong PIN
The workaround I have implemented is watchdog so everytime processor is stuck in the routine Arduino gets restarted which usually helps after 1st or 2nd restart...
Any comment on that, does anybody have same issue ?
Adding more data on AT command level, anybody knows why there is time to time SIM not present ?
AT Command level on error
20:15:40.940 -> keep alive > INIT
20:15:44.950 -> ⸮AT
20:15:45.154 -> OK
20:15:45.187 -> AT+IPR=921600
20:15:45.187 -> OK
20:15:55.392 -> SIM not present or wrong PIN
After restart and connected OK
20:17:41.930 -> keep alive > INIT
20:17:45.954 -> ⸮AT
20:17:46.159 -> OK
20:17:46.193 -> AT+IPR=921600
20:17:46.193 -> OK
20:17:46.294 -> AT
20:17:46.294 -> OK
20:17:46.328 -> AT+UPSV=3
20:17:46.328 -> OK
20:17:46.431 -> AT+CPIN?
20:17:46.431 -> ERROR
20:17:46.637 -> AT+CPIN?
20:17:46.637 -> ERROR
20:17:46.840 -> AT+CPIN?
20:17:46.840 -> ERROR
20:17:47.045 -> AT+CPIN?
20:17:47.045 -> ERROR
20:17:47.251 -> AT+CPIN?
20:17:47.251 -> +CPIN: READY
20:17:47.251 ->
20:17:47.251 -> OK
20:17:47.456 -> AT+CMGF=1
After several tests I am assuming there is a potential issue when changing baud rate...
There are 2 fixes:
void ModemClass::setBaudRate(unsigned long baud)
{
_baud = baud;
}
ModemClass MODEM(SerialGSM, 115200, GSM_RESETN, GSM_DTR);
2. Adjust delay after AT+IPR command from 100ms (it is minimal delay mention by u-blox for Sara U201 data sheet) to 200ms which seems to be more safe (not tested)
int ModemClass::begin(bool restart) { _uart->begin(_baud > 115200 ? 115200 : _baud);
if (_resetPin > -1 && restart) { pinMode(_resetPin, OUTPUT); digitalWrite(_resetPin, HIGH); delay(100); digitalWrite(_resetPin, LOW); } else { if (!autosense()) { return 0; }
if (!reset()) {
return 0;
}
}
if (!autosense()) { return 0; }
if (_baud > 115200) { sendf("AT+IPR=%ld", _baud); if (waitForResponse() != 1) { return 0; }
_uart->end();
delay(100);
_uart->begin(_baud);
if (!autosense()) {
return 0;
}
}
if (_dtrPin > -1) { pinMode(_dtrPin, OUTPUT); noLowPowerMode();
send("AT+UPSV=3");
if (waitForResponse() != 1) {
return 0;
}
}
return 1; }
Just to update, I am running on baud rate 921600 (original one) and 200ms as mentioned on point 2 and no issue for several days...
Got the same error on a different test performed, but I believe I end up in the same routine as @salvq (https://github.com/arduino-libraries/Arduino_ConnectionHandler/blob/master/src/Arduino_GSMConnectionHandler.cpp#L66-L67). My test consists in 'removing' the external antenna, having the board disconnecting from the network, then re-attaching it again and see if it reconnects. It doesn't exit from that status until a reset.
release 0.4.4 solves it for me. Commit: https://github.com/arduino-libraries/Arduino_ConnectionHandler/commit/10f0637c5bba64450727e35a262e358914256efa
@salvq could you please give it a try?
I tried and working just fine, no more stuck in SIM not present or wrong PIN routine
I am using Connection Handler to get connected to GSM network via MKR GSM 1400. From time to time when I restart or reupload the sketch and I am getting error "SIM not present or wrong PIN" attaching screenshot.
When I restart the unit (reset button) or re-upload the sketch connection is successful. Looks to me that function just finish and never continue "void GSMConnectionHandler::init()" Arduino_GSMConnectionHandler.cpp
Thanks a lot