@@ -132,53 +132,14 @@ NetworkConnectionState WiFiConnectionHandler::update_handleInit()
132132
133133NetworkConnectionState WiFiConnectionHandler::update_handleConnecting ()
134134{
135- if (WiFi.status () != NETWORK_CONNECTED ){
135+ if (WiFi.status () != WL_CONNECTED ){
136136 return NetworkConnectionState::INIT ;
137137 }
138- bool checkSuccess = false ;
139- #if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M7) || \
140- defined (ARDUINO_NICLA_VISION ) || defined (ARDUINO_OPTA ) || defined (ARDUINO_GIGA )
141- // Request time from NTP server for testing internet connection
142- UDP &udp = getUDP ();
143- udp.begin (4001 );
144- uint8_t ntp_packet_buf[48 ] = {0 };
145138
146- ntp_packet_buf[0 ] = 0b11100011 ;
147- ntp_packet_buf[1 ] = 0 ;
148- ntp_packet_buf[2 ] = 6 ;
149- ntp_packet_buf[3 ] = 0xEC ;
150- ntp_packet_buf[12 ] = 49 ;
151- ntp_packet_buf[13 ] = 0x4E ;
152- ntp_packet_buf[14 ] = 49 ;
153- ntp_packet_buf[15 ] = 52 ;
154- udp.beginPacket (" time.arduino.cc" , 123 );
155- udp.write (ntp_packet_buf, 48 );
156- udp.endPacket ();
157-
158- bool is_timeout = false ;
159- unsigned long const start = millis ();
160- do
161- {
162- is_timeout = (millis () - start) >= 1000 ;
163- } while (!is_timeout && !udp.parsePacket ());
164- if (is_timeout) {
165- udp.stop ();
166- }
167- else
168- {
169- udp.read (ntp_packet_buf, 48 );
170- udp.stop ();
171- checkSuccess = true ;
172- }
173- #else
174- int const ping_result = WiFi.ping (" time.arduino.cc" );
139+ int ping_result = WiFi.ping (" time.arduino.cc" );
175140 Debug.print (DBG_INFO , F (" WiFi.ping(): %d" ), ping_result);
176- if (ping_result > 0 )
141+ if (ping_result < 0 )
177142 {
178- checkSuccess = true ;
179- }
180- #endif
181- if (!checkSuccess){
182143 Debug.print (DBG_ERROR , F (" Internet check failed" ));
183144 Debug.print (DBG_INFO , F (" Retrying in \" %d\" milliseconds" ), CHECK_INTERVAL_TABLE [static_cast <unsigned int >(NetworkConnectionState::CONNECTING )]);
184145 return NetworkConnectionState::CONNECTING ;
0 commit comments