@@ -2301,10 +2301,7 @@ void networkStartDelayed(NetIndex_t index, uintptr_t parameter, bool debug)
2301
2301
// ----------------------------------------
2302
2302
void networkUpdate ()
2303
2303
{
2304
- bool displayIpAddress;
2305
2304
NetIndex_t index;
2306
- IPAddress ipAddress;
2307
- bool ipAddressDisplayed;
2308
2305
uint8_t networkType;
2309
2306
NETWORK_POLL_ROUTINE pollRoutine;
2310
2307
uint8_t priority;
@@ -2389,44 +2386,62 @@ void networkUpdate()
2389
2386
webServerUpdate (); // Start webServer for web config as needed
2390
2387
2391
2388
// Periodically display the network interface state
2392
- displayIpAddress = PERIODIC_DISPLAY (PD_IP_ADDRESS);
2393
- for (int index = 0 ; index < NETWORK_OFFLINE; index++)
2389
+ if (PERIODIC_DISPLAY (PD_NETWORK_STATE))
2394
2390
{
2395
- // Display the current state
2396
- ipAddressDisplayed = displayIpAddress && (index == networkPriority);
2397
- if (PERIODIC_DISPLAY (networkInterfaceTable[index].pdState ) || PERIODIC_DISPLAY (PD_NETWORK_STATE) ||
2398
- ipAddressDisplayed)
2399
- {
2391
+ PERIODIC_CLEAR (PD_NETWORK_STATE);
2392
+ PERIODIC_CLEAR (PD_IP_ADDRESS);
2393
+ for (int index = 0 ; index < NETWORK_OFFLINE; index++)
2400
2394
PERIODIC_CLEAR (networkInterfaceTable[index].pdState );
2401
- if (networkInterfaceTable[index].netif ->hasIP ())
2402
- {
2403
- ipAddress = networkInterfaceTable[index].netif ->localIP ();
2404
- systemPrintf (" %s: %s%s\r\n " , networkInterfaceTable[index].name , ipAddress.toString ().c_str (),
2405
- networkInterfaceTable[index].netif ->isDefault () ? " (default)" : " " );
2406
- }
2407
- else if (networkInterfaceTable[index].netif ->linkUp ())
2408
- systemPrintf (" %s: Link Up\r\n " , networkInterfaceTable[index].name );
2409
- else if (networkInterfaceTable[index].netif ->started ())
2410
- systemPrintf (" %s: Started\r\n " , networkInterfaceTable[index].name );
2411
2395
2412
- else if (index == NETWORK_WIFI_STATION && (WiFi.getMode () == WIFI_AP || WiFi.getMode () == WIFI_AP_STA))
2413
- {
2414
- // NETIF doesn't capture the IP address of a soft AP
2415
- ipAddress = WiFi.softAPIP ();
2416
- systemPrintf (" %s: %s%s\r\n " , networkInterfaceTable[index].name , ipAddress.toString ().c_str (),
2417
- networkInterfaceTable[index].netif ->isDefault () ? " (default)" : " " );
2418
- }
2419
- else
2420
- systemPrintf (" %s: Stopped\r\n " , networkInterfaceTable[index].name );
2421
- }
2396
+ // Display the network state
2397
+ networkDisplayStatus ();
2422
2398
}
2423
- if ( PERIODIC_DISPLAY (PD_NETWORK_STATE))
2424
- PERIODIC_CLEAR (PD_NETWORK_STATE);
2425
- if (displayIpAddress )
2399
+
2400
+ // Periodically display the IP address
2401
+ else if (PERIODIC_DISPLAY (PD_IP_ADDRESS) )
2426
2402
{
2427
- if (!ipAddressDisplayed)
2428
- systemPrintln (" Network: Offline" );
2403
+ int index;
2404
+ IPAddress ipAddress;
2405
+
2429
2406
PERIODIC_CLEAR (PD_IP_ADDRESS);
2407
+
2408
+ // Display the IP address of the highest priority network
2409
+ index = networkPriorityTable[networkPriority];
2410
+ if ((index < NETWORK_OFFLINE)
2411
+ && networkInterfaceHasInternet (index)
2412
+ && networkInterfaceTable[index].netif ->hasIP ())
2413
+ {
2414
+ ipAddress = networkInterfaceTable[index].netif ->localIP ();
2415
+ systemPrintf (" %s: %s%s\r\n " ,
2416
+ networkInterfaceTable[index].name ,
2417
+ ipAddress.toString ().c_str (),
2418
+ networkInterfaceTable[index].netif ->isDefault () ? " (default)" : " " );
2419
+ }
2420
+ else
2421
+ systemPrintf (" Network: Offline\r\n " );
2422
+
2423
+ // Display the soft AP IP address
2424
+ if (wifiSoftApOnline)
2425
+ {
2426
+ ipAddress = wifiSoftApGetIpAddress ();
2427
+ systemPrintf (" WiFi Soft AP: %s\r\n " , ipAddress.toString ().c_str ());
2428
+ }
2429
+ else
2430
+ systemPrintf (" WiFi Soft AP: Offline\r\n " );
2431
+ }
2432
+
2433
+ // Periodically display an interface state
2434
+ else
2435
+ {
2436
+ for (int index = 0 ; index < NETWORK_OFFLINE; index++)
2437
+ if (PERIODIC_DISPLAY (networkInterfaceTable[index].pdState ))
2438
+ {
2439
+ PERIODIC_CLEAR (networkInterfaceTable[index].pdState );
2440
+
2441
+ // Display the state for an interface
2442
+ networkPrintStatus (index);
2443
+ networkDisplayInterface (index);
2444
+ }
2430
2445
}
2431
2446
}
2432
2447
0 commit comments