Skip to content

Commit 13e490d

Browse files
authored
Merge pull request #36 from arduino-libraries/fix-gsm-when-ping-broken
Bugfix: Don't break MKRGSM stack when ping fails.
2 parents 437fd91 + 21825b4 commit 13e490d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Arduino_GSMConnectionHandler.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,15 @@ unsigned long GSMConnectionHandler::getTime()
5858

5959
NetworkConnectionState GSMConnectionHandler::update_handleInit()
6060
{
61-
if (_gsm.begin(_pin) == GSM_READY)
62-
{
63-
Debug.print(DBG_INFO, "SIM card ok");
64-
_gsm.setTimeout(GSM_TIMEOUT);
65-
return NetworkConnectionState::CONNECTING;
66-
}
67-
else
61+
if (_gsm.begin(_pin) != GSM_READY)
6862
{
6963
Debug.print(DBG_ERROR, "SIM not present or wrong PIN");
7064
return NetworkConnectionState::ERROR;
7165
}
72-
}
7366

74-
NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
75-
{
67+
Debug.print(DBG_INFO, "SIM card ok");
68+
_gsm.setTimeout(GSM_TIMEOUT);
69+
7670
GSM3_NetworkStatus_t const network_status = _gprs.attachGPRS(_apn, _login, _pass, true);
7771
Debug.print(DBG_DEBUG, "GPRS.attachGPRS(): %d", network_status);
7872
if (network_status == GSM3_NetworkStatus_t::ERROR)
@@ -81,6 +75,12 @@ NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
8175
Debug.print(DBG_ERROR, "Make sure the antenna is connected and reset your board.");
8276
return NetworkConnectionState::ERROR;
8377
}
78+
79+
return NetworkConnectionState::CONNECTING;
80+
}
81+
82+
NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
83+
{
8484
Debug.print(DBG_INFO, "Sending PING to outer space...");
8585
int const ping_result = _gprs.ping("time.arduino.cc");
8686
Debug.print(DBG_INFO, "GPRS.ping(): %d", ping_result);

0 commit comments

Comments
 (0)