@@ -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,23 @@ 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
96
+ Serial.println (_check_internet_availability);
97
+
93
98
if (!_check_internet_availability){
94
99
return NetworkConnectionState::CONNECTED;
95
100
}
96
101
97
- int ping_result = GSM.ping (" time.arduino.cc" );
102
+ Debug.print (DBG_INFO, F (" Sending PING to outer space..." ));
103
+ int const ping_result = GSM.ping (" time.arduino.cc" );
98
104
Debug.print (DBG_INFO, F (" GSM.ping(): %d" ), ping_result);
99
105
if (ping_result < 0 )
100
106
{
101
107
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)]);
108
+ Debug.print (DBG_INFO, F (" Retrying in \" %d\" milliseconds" ), 2 * CHECK_INTERVAL_TABLE[static_cast <unsigned int >(NetworkConnectionState::CONNECTING)]);
103
109
return NetworkConnectionState::CONNECTING;
104
110
}
105
111
else
@@ -114,6 +120,7 @@ NetworkConnectionState CatM1ConnectionHandler::update_handleConnected()
114
120
int const is_gsm_access_alive = GSM.isConnected ();
115
121
if (is_gsm_access_alive != 1 )
116
122
{
123
+ Debug.print (DBG_ERROR, F (" GSM connection not alive... disconnecting" ));
117
124
return NetworkConnectionState::DISCONNECTED;
118
125
}
119
126
return NetworkConnectionState::CONNECTED;
0 commit comments