Skip to content

Commit 236d189

Browse files
committed
Network: Update periodically display to show more data
1 parent c35768f commit 236d189

File tree

2 files changed

+51
-35
lines changed

2 files changed

+51
-35
lines changed

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ uint32_t wifiGetStartTimeout() {return 0;}
214214
int wifiNetworkCount() {return 0;}
215215
void wifiResetThrottleTimeout() {}
216216
void wifiResetTimeout() {}
217+
IPAddress wifiSoftApGetIpAddress() {return IPAddress((uint32_t)0);}
217218
const char * wifiSoftApGetSsid() {return "";}
218219
bool wifiSoftApOff(const char * fileName, uint32_t lineNumber) {return true;}
219220
bool wifiSoftApOn(const char * fileName, uint32_t lineNumber) {return false;}

Firmware/RTK_Everywhere/Network.ino

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,10 +2301,7 @@ void networkStartDelayed(NetIndex_t index, uintptr_t parameter, bool debug)
23012301
//----------------------------------------
23022302
void networkUpdate()
23032303
{
2304-
bool displayIpAddress;
23052304
NetIndex_t index;
2306-
IPAddress ipAddress;
2307-
bool ipAddressDisplayed;
23082305
uint8_t networkType;
23092306
NETWORK_POLL_ROUTINE pollRoutine;
23102307
uint8_t priority;
@@ -2389,44 +2386,62 @@ void networkUpdate()
23892386
webServerUpdate(); // Start webServer for web config as needed
23902387

23912388
// 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))
23942390
{
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++)
24002394
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);
24112395

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();
24222398
}
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))
24262402
{
2427-
if (!ipAddressDisplayed)
2428-
systemPrintln("Network: Offline");
2403+
int index;
2404+
IPAddress ipAddress;
2405+
24292406
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+
}
24302445
}
24312446
}
24322447

0 commit comments

Comments
 (0)