Where to begin()

A number of posts on this forum describe how code hangs when the GSM signal is lost. The problem is in the begin() function and occurs even in the example code at http://arduino.cc/en/Reference/GSMBegin , e.g., when the SIM card is removed.

Following a clue provided by armin (Code hangs in interrupt when there is poor GSM signal - Arduino GSM Shield - Arduino Forum) I took a closer look at the GSM3ShieldV1AccessProvider::ModemConfigurationContinue() function in GSM3ShieldV1AccessProvider.cpp and found the root of the problem to be the first call to theGSM3ShieldV1ModemCore.takeMilliseconds(). By commenting out this call, the example code works as it should (but note that it occurs two more times).

I also noticed that the functions GSM3ShieldV1AccessProvider::HWrestart() and GSM3ShieldV1AccessProvider::HWstart() in GSM3ShieldV1AccessProvider.cpp are identical except for an increased delay of 10 seconds in the former. As far as I can tell, this has no effect. Hence, it doesn’t actually matter what value is given to the second parameter in the begin() function, the result is the same!

I’d be interested in your comments.