@@ -37,6 +37,8 @@ CatM1ConnectionHandler::CatM1ConnectionHandler(
37
37
: ConnectionHandler{keep_alive, NetworkAdapter::CATM1}
38
38
{
39
39
_settings.type = NetworkAdapter::CATM1;
40
+ // To keep the backward compatibility, the user can call enableCheckInternetAvailability(false) for disabling the check
41
+ _check_internet_availability = true ;
40
42
strncpy (_settings.catm1 .pin , pin, sizeof (_settings.catm1 .pin )-1 );
41
43
strncpy (_settings.catm1 .apn , apn, sizeof (_settings.catm1 .apn )-1 );
42
44
strncpy (_settings.catm1 .login , login, sizeof (_settings.catm1 .login )-1 );
@@ -87,19 +89,21 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleConnecting()
87
89
{
88
90
if (!GSM.isConnected ())
89
91
{
90
- return NetworkConnectionState::INIT;
92
+ Debug.print (DBG_ERROR, F (" GSM connection not alive... disconnecting" ));
93
+ return NetworkConnectionState::DISCONNECTED;
91
94
}
92
95
93
96
if (!_check_internet_availability){
94
97
return NetworkConnectionState::CONNECTED;
95
98
}
96
99
97
- int ping_result = GSM.ping (" time.arduino.cc" );
100
+ Debug.print (DBG_INFO, F (" Sending PING to outer space..." ));
101
+ int const ping_result = GSM.ping (" time.arduino.cc" );
98
102
Debug.print (DBG_INFO, F (" GSM.ping(): %d" ), ping_result);
99
103
if (ping_result < 0 )
100
104
{
101
105
Debug.print (DBG_ERROR, F (" Internet check failed" ));
102
- Debug.print (DBG_INFO, F (" Retrying in \" %d\" milliseconds" ), CHECK_INTERVAL_TABLE[static_cast <unsigned int >(NetworkConnectionState::CONNECTING)]);
106
+ Debug.print (DBG_INFO, F (" Retrying in \" %d\" milliseconds" ), 2 * CHECK_INTERVAL_TABLE[static_cast <unsigned int >(NetworkConnectionState::CONNECTING)]);
103
107
return NetworkConnectionState::CONNECTING;
104
108
}
105
109
else
@@ -114,6 +118,7 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleConnected()
114
118
int const is_gsm_access_alive = GSM.isConnected ();
115
119
if (is_gsm_access_alive != 1 )
116
120
{
121
+ Debug.print (DBG_ERROR, F (" GSM connection not alive... disconnecting" ));
117
122
return NetworkConnectionState::DISCONNECTED;
118
123
}
119
124
return NetworkConnectionState::CONNECTED;
0 commit comments