Description
Hi,
I have a MKRGSM1400 board. When connecting to cloud I have the following messages in serial monitor:
20:35:20.787 -> SIM card ok
20:35:24.801 -> GPRS.attachGPRS(): 4
20:35:24.801 -> Sending PING to outer space...
20:35:29.814 -> GPRS.ping(): -2
20:35:29.814 -> PING failed
20:35:29.814 -> Retrying in "500" milliseconds
20:35:30.131 -> GPRS.attachGPRS(): 0
20:35:30.131 -> GPRS attach failed
20:35:30.131 -> Make sure the antenna is connected and reset your board.
Then the board stop connecting and I have to reset.
Looking at Arduino_GSMConnectionHandler.cpp
, but I am not an expert, I see the following code:
NetworkConnectionState GSMConnectionHandler::update_handleConnecting()
{
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)
{
Debug.print(DBG_ERROR, "GPRS attach failed");
Debug.print(DBG_ERROR, "Make sure the antenna is connected and reset your board.");
return NetworkConnectionState::ERROR;
}
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);
if (ping_result < 0)
{
Debug.print(DBG_ERROR, "PING failed");
Debug.print(DBG_INFO, "Retrying in \"%d\" milliseconds", CHECK_INTERVAL_TABLE[static_cast<unsigned int>(NetworkConnectionState::CONNECTING)]);
return NetworkConnectionState::CONNECTING;
}
else
{
Debug.print(DBG_INFO, "Connected to GPRS Network");
return NetworkConnectionState::CONNECTED;
}
}
The first time GPRS.attachGPRS()
run successfully but the ping end with -2 so the program try to reconnect again.
The second time GPRS.attachGPRS()
run with error, maybe because the GPRS is already connected?
I see in my test that the first ping always end with -2
, but putting the ping inside a loop the second or third ping end successfully. I don't know why the first ping is always -2
.
So what is the problem? The ping should be put inside a loop or the problem is the attachGPRS
?
Please help.
Thanks.