Skip to content

Bugfix: Don't break MKRGSM stack when ping fails. #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Arduino_GSMConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,15 @@ unsigned long GSMConnectionHandler::getTime()

NetworkConnectionState GSMConnectionHandler::update_handleInit()
{
if (_gsm.begin(_pin) == GSM_READY)
{
Debug.print(DBG_INFO, "SIM card ok");
_gsm.setTimeout(GSM_TIMEOUT);
return NetworkConnectionState::CONNECTING;
}
else
if (_gsm.begin(_pin) != GSM_READY)
{
Debug.print(DBG_ERROR, "SIM not present or wrong PIN");
return NetworkConnectionState::ERROR;
}
}

NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
{
Debug.print(DBG_INFO, "SIM card ok");
_gsm.setTimeout(GSM_TIMEOUT);

GSM3_NetworkStatus_t const network_status = _gprs.attachGPRS(_apn, _login, _pass, true);
Debug.print(DBG_DEBUG, "GPRS.attachGPRS(): %d", network_status);
if (network_status == GSM3_NetworkStatus_t::ERROR)
Expand All @@ -81,6 +75,12 @@ NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
Debug.print(DBG_ERROR, "Make sure the antenna is connected and reset your board.");
return NetworkConnectionState::ERROR;
}

return NetworkConnectionState::CONNECTING;
}

NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
{
Debug.print(DBG_INFO, "Sending PING to outer space...");
int const ping_result = _gprs.ping("time.arduino.cc");
Debug.print(DBG_INFO, "GPRS.ping(): %d", ping_result);
Expand Down