OK, I figured it out. Following Code hangs in interrupt when there is poor GSM signal - Arduino GSM Shield - Arduino Forum, it seems the problem occurs when starting communication with the GSM module and a reply is never recieved. So, to fix the stuck on AT%13% bug, simply change this in GSM3ShieldV1AccessProvider.cpp:
GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart, bool synchronous)
{
pinMode(__RESETPIN__, OUTPUT);
// If asked for modem restart, restart
if (restart)
HWrestart();
else
HWstart();
theGSM3ShieldV1ModemCore.gss.begin(9600);
// Launch modem configuration commands
ModemConfiguration(pin);
// If synchronous, wait till ModemConfiguration is over
if(synchronous)
{
// if we shorten this delay, the command fails
while(ready()==0)
delay(1000);
}
return getStatus();
}
To this:
GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart, bool synchronous)
{
Serial.println("gsm.begin()");
pinMode(__RESETPIN__, OUTPUT);
// If asked for modem restart, restart
if (restart)
{
HWrestart();
}
else
{
HWstart();
}
unsigned loopCnt = 30;
theGSM3ShieldV1ModemCore.gss.begin(9600);
// Launch modem configuration commands
ModemConfiguration(pin);
// If synchronous, wait till ModemConfiguration is over
if(synchronous)
{
// if we shorten this delay, the command fails
while(ready()==0 && loopCnt--)
{
delay(1000);
Serial.println("gsm.begin() waiting for ready");
}
}
return getStatus();
}
This way, even if the hang occurs, it is timed out properly.