@@ -102,6 +102,10 @@ NetworkConnectionState NBConnectionHandler::update_handleInit()
102102 Debug.print (DBG_ERROR, F (" SIM not present or wrong PIN" ));
103103 return NetworkConnectionState::ERROR;
104104 }
105+ }
106+
107+ NetworkConnectionState NBConnectionHandler::update_handleConnecting ()
108+ {
105109 NB_NetworkStatus_t const network_status = _nb_gprs.attachGPRS (true );
106110 Debug.print (DBG_DEBUG, F (" GPRS.attachGPRS(): %d" ), network_status);
107111 if (network_status == NB_NetworkStatus_t::NB_ERROR)
@@ -112,32 +116,6 @@ NetworkConnectionState NBConnectionHandler::update_handleInit()
112116 else
113117 {
114118 Debug.print (DBG_INFO, F (" Connected to GPRS Network" ));
115- return NetworkConnectionState::CONNECTING;
116- }
117-
118- }
119-
120- NetworkConnectionState NBConnectionHandler::update_handleConnecting ()
121- {
122- if (_nb.isAccessAlive () != 1 ){
123- return NetworkConnectionState::INIT;
124- }
125-
126- if (!_check_internet_availability){
127- return NetworkConnectionState::CONNECTED;
128- }
129-
130- int ping_result = _nb_gprs.ping (" time.arduino.cc" );
131- Debug.print (DBG_INFO, F (" GPRS.ping(): %d" ), ping_result);
132- if (ping_result < 0 )
133- {
134- Debug.print (DBG_ERROR, F (" Internet check failed" ));
135- Debug.print (DBG_INFO, F (" Retrying in \" %d\" milliseconds" ), CHECK_INTERVAL_TABLE[static_cast <unsigned int >(NetworkConnectionState::CONNECTING)]);
136- return NetworkConnectionState::CONNECTING;
137- }
138- else
139- {
140- Debug.print (DBG_INFO, F (" Connected to Internet" ));
141119 return NetworkConnectionState::CONNECTED;
142120 }
143121}
0 commit comments