@@ -441,6 +441,42 @@ static bool wifiStationRunning;
441
441
static int wifiFailedConnectionAttempts = 0 ; // Count the number of connection attempts between restarts
442
442
static WiFiMulti *wifiMulti;
443
443
444
+ // *********************************************************************
445
+ // Display the WiFi state
446
+ void wifiDisplayState ()
447
+ {
448
+ systemPrintf (" WiFi: %s\r\n " , networkInterfaceHasInternet (NETWORK_WIFI) ? " Online" : " Offline" );
449
+ systemPrintf (" MAC Address: %02X:%02X:%02X:%02X:%02X:%02X\r\n " , wifiMACAddress[0 ], wifiMACAddress[1 ],
450
+ wifiMACAddress[2 ], wifiMACAddress[3 ], wifiMACAddress[4 ], wifiMACAddress[5 ]);
451
+ if (networkInterfaceHasInternet (NETWORK_WIFI))
452
+ {
453
+ // Get the DNS addresses
454
+ IPAddress dns1 = WiFi.STA .dnsIP (0 );
455
+ IPAddress dns2 = WiFi.STA .dnsIP (1 );
456
+ IPAddress dns3 = WiFi.STA .dnsIP (2 );
457
+
458
+ // Get the WiFi status
459
+ wl_status_t wifiStatus = WiFi.status ();
460
+
461
+ const char *wifiStatusString = wifiPrintState (wifiStatus);
462
+
463
+ // Display the WiFi state
464
+ systemPrintf (" SSID: %s\r\n " , WiFi.STA .SSID ());
465
+ systemPrintf (" IP Address: %s\r\n " , WiFi.STA .localIP ().toString ().c_str ());
466
+ systemPrintf (" Subnet Mask: %s\r\n " , WiFi.STA .subnetMask ().toString ().c_str ());
467
+ systemPrintf (" Gateway Address: %s\r\n " , WiFi.STA .gatewayIP ().toString ().c_str ());
468
+ if ((uint32_t )dns3)
469
+ systemPrintf (" DNS Address: %s, %s, %s\r\n " , dns1.toString ().c_str (), dns2.toString ().c_str (),
470
+ dns3.toString ().c_str ());
471
+ else if ((uint32_t )dns3)
472
+ systemPrintf (" DNS Address: %s, %s\r\n " , dns1.toString ().c_str (), dns2.toString ().c_str ());
473
+ else
474
+ systemPrintf (" DNS Address: %s\r\n " , dns1.toString ().c_str ());
475
+ systemPrintf (" WiFi Strength: %d dBm\r\n " , WiFi.RSSI ());
476
+ systemPrintf (" WiFi Status: %d (%s)\r\n " , wifiStatus, wifiStatusString);
477
+ }
478
+ }
479
+
444
480
// *********************************************************************
445
481
// Counts the number of entered SSIDs
446
482
int wifiNetworkCount ()
@@ -2861,43 +2897,6 @@ bool wifiConnect(bool startWiFiStation, bool startWiFiAP, unsigned long timeout)
2861
2897
return false ;
2862
2898
}
2863
2899
2864
- // ----------------------------------------
2865
- // Display the WiFi state
2866
- // ----------------------------------------
2867
- void wifiDisplayState ()
2868
- {
2869
- systemPrintf (" WiFi: %s\r\n " , networkInterfaceHasInternet (NETWORK_WIFI) ? " Online" : " Offline" );
2870
- systemPrintf (" MAC Address: %02X:%02X:%02X:%02X:%02X:%02X\r\n " , wifiMACAddress[0 ], wifiMACAddress[1 ],
2871
- wifiMACAddress[2 ], wifiMACAddress[3 ], wifiMACAddress[4 ], wifiMACAddress[5 ]);
2872
- if (networkInterfaceHasInternet (NETWORK_WIFI))
2873
- {
2874
- // Get the DNS addresses
2875
- IPAddress dns1 = WiFi.STA .dnsIP (0 );
2876
- IPAddress dns2 = WiFi.STA .dnsIP (1 );
2877
- IPAddress dns3 = WiFi.STA .dnsIP (2 );
2878
-
2879
- // Get the WiFi status
2880
- wl_status_t wifiStatus = WiFi.status ();
2881
-
2882
- const char *wifiStatusString = wifiPrintState (wifiStatus);
2883
-
2884
- // Display the WiFi state
2885
- systemPrintf (" SSID: %s\r\n " , WiFi.STA .SSID ());
2886
- systemPrintf (" IP Address: %s\r\n " , WiFi.STA .localIP ().toString ().c_str ());
2887
- systemPrintf (" Subnet Mask: %s\r\n " , WiFi.STA .subnetMask ().toString ().c_str ());
2888
- systemPrintf (" Gateway Address: %s\r\n " , WiFi.STA .gatewayIP ().toString ().c_str ());
2889
- if ((uint32_t )dns3)
2890
- systemPrintf (" DNS Address: %s, %s, %s\r\n " , dns1.toString ().c_str (), dns2.toString ().c_str (),
2891
- dns3.toString ().c_str ());
2892
- else if ((uint32_t )dns3)
2893
- systemPrintf (" DNS Address: %s, %s\r\n " , dns1.toString ().c_str (), dns2.toString ().c_str ());
2894
- else
2895
- systemPrintf (" DNS Address: %s\r\n " , dns1.toString ().c_str ());
2896
- systemPrintf (" WiFi Strength: %d dBm\r\n " , WiFi.RSSI ());
2897
- systemPrintf (" WiFi Status: %d\r\n " , wifiStatusString);
2898
- }
2899
- }
2900
-
2901
2900
// ----------------------------------------
2902
2901
// Process the WiFi events
2903
2902
// ----------------------------------------
0 commit comments