Open aylashiv opened 4 years ago
The flaky behaviour is caused in the communication between the modem and the network, the mkrgsm lib is just sending the correct AT commands to the modem. If you use the sample sketch, the whole process braced with a while commmand stops somewhen. This makes the start suceed unpredictable. The start can also hang while changing the baud rate:
See https://github.com/arduino-libraries/MKRGSM/pull/123
For me, i did a primitive startup solution with good results:
int gsm_conn_counter = 0; do { gsmAccess.begin(PINNUMBER); gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD); if ((gsmAccess.begin(PINNUMBER) == GSM_READY) && (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY) ) { connected = true; Serial.print("Mobile Uplink Ready!"); delay(1000); break; } else { Serial.print("Mobile Uplink Not Ready! Trying again.."); delay(1000); if (gsm_conn_counter > 3) { Serial.print("Start without Mobile Network.."); delay(2000); } gsm_conn_counter ++; } } while (gsm_conn_counter <= 2);
Hi,
I have been using the MKRGSM library and MKR1400 Board, for our application, were it connects to the Azure IoT hub for every 2.5 minutes and relays the data to the hub, the potential issue lies in the GSMcpp file were the modem.begin function calls the CREG command, this CREG command is a blocking call, therefore the program stops for the response untill it does not respind with CREG:0,1. Though we have tried with timeout approach by introducing a certain time limit to try and gets out of the blocking loop, but the program behaves differently, we have tried with serial prints to know were exactly the Program Hangs, but no gain. we are totally clueless at which point it gets hang even though the timeout has been introduced,
I Seek Suggestions from the Arduino Software community/makers, could help us solve this issue.