@@ -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;
@@ -2317,18 +2314,8 @@ void networkUpdate()
2317
2314
2318
2315
// Handle the network lost internet event
2319
2316
if (networkEventInternetLost[index])
2320
- {
2321
2317
networkInterfaceInternetConnectionLost (index);
2322
2318
2323
- // Attempt to restart WiFi
2324
- if ((index == NETWORK_WIFI_STATION) && (networkIsHighestPriority (index)))
2325
- {
2326
- if (networkIsStarted (index))
2327
- networkStop (index, settings.debugWifiState , __FILE__, __LINE__);
2328
- networkStart (index, settings.debugWifiState , __FILE__, __LINE__);
2329
- }
2330
- }
2331
-
2332
2319
// Handle the network stop event
2333
2320
if (networkEventStop[index])
2334
2321
networkStop (index, settings.debugNetworkLayer , __FILE__, __LINE__);
@@ -2363,6 +2350,9 @@ void networkUpdate()
2363
2350
}
2364
2351
}
2365
2352
2353
+ // Update the WiFi state
2354
+ wifiStationUpdate ();
2355
+
2366
2356
// Update the network services
2367
2357
// Start or stop mDNS
2368
2358
if (networkMdnsRequests != networkMdnsRunning)
@@ -2389,44 +2379,62 @@ void networkUpdate()
2389
2379
webServerUpdate (); // Start webServer for web config as needed
2390
2380
2391
2381
// Periodically display the network interface state
2392
- displayIpAddress = PERIODIC_DISPLAY (PD_IP_ADDRESS);
2393
- for (int index = 0 ; index < NETWORK_OFFLINE; index++)
2382
+ if (PERIODIC_DISPLAY (PD_NETWORK_STATE))
2394
2383
{
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
- {
2384
+ PERIODIC_CLEAR (PD_NETWORK_STATE);
2385
+ PERIODIC_CLEAR (PD_IP_ADDRESS);
2386
+ for (int index = 0 ; index < NETWORK_OFFLINE; index++)
2400
2387
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
2388
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
- }
2389
+ // Display the network state
2390
+ networkDisplayStatus ();
2422
2391
}
2423
- if ( PERIODIC_DISPLAY (PD_NETWORK_STATE))
2424
- PERIODIC_CLEAR (PD_NETWORK_STATE);
2425
- if (displayIpAddress )
2392
+
2393
+ // Periodically display the IP address
2394
+ else if (PERIODIC_DISPLAY (PD_IP_ADDRESS) )
2426
2395
{
2427
- if (!ipAddressDisplayed)
2428
- systemPrintln (" Network: Offline" );
2396
+ int index;
2397
+ IPAddress ipAddress;
2398
+
2429
2399
PERIODIC_CLEAR (PD_IP_ADDRESS);
2400
+
2401
+ // Display the IP address of the highest priority network
2402
+ index = networkPriorityTable[networkPriority];
2403
+ if ((index < NETWORK_OFFLINE)
2404
+ && networkInterfaceHasInternet (index)
2405
+ && networkInterfaceTable[index].netif ->hasIP ())
2406
+ {
2407
+ ipAddress = networkInterfaceTable[index].netif ->localIP ();
2408
+ systemPrintf (" %s: %s%s\r\n " ,
2409
+ networkInterfaceTable[index].name ,
2410
+ ipAddress.toString ().c_str (),
2411
+ networkInterfaceTable[index].netif ->isDefault () ? " (default)" : " " );
2412
+ }
2413
+ else
2414
+ systemPrintf (" Network: Offline\r\n " );
2415
+
2416
+ // Display the soft AP IP address
2417
+ if (wifiSoftApOnline)
2418
+ {
2419
+ ipAddress = wifiSoftApGetIpAddress ();
2420
+ systemPrintf (" WiFi Soft AP: %s\r\n " , ipAddress.toString ().c_str ());
2421
+ }
2422
+ else
2423
+ systemPrintf (" WiFi Soft AP: Offline\r\n " );
2424
+ }
2425
+
2426
+ // Periodically display an interface state
2427
+ else
2428
+ {
2429
+ for (int index = 0 ; index < NETWORK_OFFLINE; index++)
2430
+ if (PERIODIC_DISPLAY (networkInterfaceTable[index].pdState ))
2431
+ {
2432
+ PERIODIC_CLEAR (networkInterfaceTable[index].pdState );
2433
+
2434
+ // Display the state for an interface
2435
+ networkPrintStatus (index);
2436
+ networkDisplayInterface (index);
2437
+ }
2430
2438
}
2431
2439
}
2432
2440
0 commit comments