Skip to content

Commit 514623c

Browse files
authored
Merge branch 'release_candidate' into PointPerfectRTCM
2 parents cda1769 + 1546560 commit 514623c

File tree

9 files changed

+503
-337
lines changed

9 files changed

+503
-337
lines changed

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,19 @@ void wifiDisplaySoftApStatus() {}
211211
bool wifiEspNowOff(const char * fileName, uint32_t lineNumber) {return true;}
212212
bool wifiEspNowOn(const char * fileName, uint32_t lineNumber) {return false;}
213213
void wifiEspNowSetChannel(WIFI_CHANNEL_t channel) {}
214-
uint32_t wifiGetStartTimeout() {return 0;}
215214
int wifiNetworkCount() {return 0;}
216-
void wifiResetThrottleTimeout() {}
217215
void wifiResetTimeout() {}
216+
IPAddress wifiSoftApGetIpAddress() {return IPAddress((uint32_t)0);}
218217
const char * wifiSoftApGetSsid() {return "";}
219218
bool wifiSoftApOff(const char * fileName, uint32_t lineNumber) {return true;}
220219
bool wifiSoftApOn(const char * fileName, uint32_t lineNumber) {return false;}
220+
void wifiStationDisplayData() {}
221221
bool wifiStationOff(const char * fileName, uint32_t lineNumber) {return true;}
222222
bool wifiStationOn(const char * fileName, uint32_t lineNumber) {return false;}
223+
void wifiStationUpdate() {}
223224
void wifiStopAll() {}
225+
void wifiUpdateSettings() {}
226+
void wifiVerifyTables() {}
224227

225228
#endif // COMPILE_WIFI
226229

Firmware/RTK_Everywhere/Network.ino

Lines changed: 104 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ void menuTcpUdp()
201201
systemPrintf("7) UDP Server Port: %ld\r\n", settings.udpServerPort);
202202

203203
if (settings.enableTcpServer)
204+
{
204205
systemPrintf("8) Enable NTRIP Caster: %s\r\n", settings.enableNtripCaster ? "Enabled" : "Disabled");
206+
systemPrintf("9) Enable base Caster override: %s\r\n", settings.baseCasterOverride ? "Enabled" : "Disabled");
207+
}
205208

206209
//------------------------------
207210
// Display the mDNS server menu items
@@ -286,6 +289,9 @@ void menuTcpUdp()
286289
else if (incoming == 8 && settings.enableTcpServer)
287290
settings.enableNtripCaster ^= 1;
288291

292+
else if (incoming == 9 && settings.enableTcpServer)
293+
settings.baseCasterOverride ^= 1;
294+
289295
//------------------------------
290296
// Get the mDNS server parameters
291297
//------------------------------
@@ -485,10 +491,18 @@ NETCONSUMER_MASK_t networkConsumerBits(NetIndex_t index)
485491
return networkConsumersAny | netIfConsumers[index];
486492
}
487493

494+
//----------------------------------------
495+
// Count the number of network consumers
496+
//----------------------------------------
497+
int networkConsumerCount(NetIndex_t index)
498+
{
499+
return networkConsumerCountBits(networkConsumerBits(index));
500+
}
501+
488502
//----------------------------------------
489503
// Count the network consumer bits
490504
//----------------------------------------
491-
int networkConsumerCount(NETCONSUMER_MASK_t bits)
505+
int networkConsumerCountBits(NETCONSUMER_MASK_t bits)
492506
{
493507
int bitCount;
494508
NETCONSUMER_MASK_t bitMask;
@@ -527,7 +541,7 @@ void networkConsumerDisplay()
527541
bits |= netIfConsumers[index];
528542
users = netIfUsers[index];
529543
}
530-
systemPrintf("Network Consumers: %d", networkConsumerCount(bits));
544+
systemPrintf("Network Consumers: %d", networkConsumerCountBits(bits));
531545
networkConsumerPrint(bits, users, ", ");
532546
systemPrintln();
533547

@@ -672,7 +686,10 @@ void networkConsumerRemove(NETCONSUMER_t consumer, NetIndex_t network, const cha
672686
{
673687
// Display the consumer
674688
if (settings.debugNetworkLayer)
689+
{
690+
networkDisplayStatus();
675691
systemPrintf("Network: Stopping the networks\r\n");
692+
}
676693

677694
// Walk the networks in increasing priority
678695
// Turn off the lower priority networks first to eliminate failover
@@ -758,6 +775,10 @@ void networkDisplayInterface(NetIndex_t index)
758775
networkValidateIndex(index);
759776
entry = &networkInterfaceTable[index];
760777
networkDisplayNetworkData(entry->name, entry->netif);
778+
779+
// Display additional WiFi data
780+
if (index == NETWORK_WIFI_STATION)
781+
wifiStationDisplayData();
761782
}
762783

763784
//----------------------------------------
@@ -1363,7 +1384,7 @@ void networkInterfaceInternetConnectionLost(NetIndex_t index)
13631384
bool networkIsHighestPriority(NetIndex_t index)
13641385
{
13651386
NetPriority_t priority;
1366-
bool higherPriority;
1387+
bool highestPriority;
13671388

13681389
// Validate the index
13691390
networkValidateIndex(index);
@@ -1372,10 +1393,10 @@ bool networkIsHighestPriority(NetIndex_t index)
13721393
priority = networkPriority;
13731394

13741395
// Determine if the specified interface has higher priority
1375-
higherPriority = (priority == NETWORK_OFFLINE);
1376-
if (!higherPriority)
1377-
higherPriority = (priority > networkPriorityTable[index]);
1378-
return higherPriority;
1396+
highestPriority = (priority == NETWORK_OFFLINE);
1397+
if (highestPriority == false)
1398+
highestPriority = (priority >= networkPriorityTable[index]);
1399+
return highestPriority;
13791400
}
13801401

13811402
//----------------------------------------
@@ -1536,7 +1557,7 @@ void networkPrintStatus(uint8_t priority)
15361557
{
15371558
NetMask_t bitMask;
15381559
NETCONSUMER_MASK_t consumerMask;
1539-
NETCONSUMER_t consumers;
1560+
NETCONSUMER_MASK_t consumers;
15401561
bool highestPriority;
15411562
int index;
15421563
const char *name;
@@ -2020,7 +2041,7 @@ NETCONSUMER_MASK_t networkSoftApConsumerBits()
20202041
//----------------------------------------
20212042
void networkSoftApConsumerDisplay()
20222043
{
2023-
systemPrintf("WiFi Soft AP Consumers: %d", networkConsumerCount(networkSoftApConsumer));
2044+
systemPrintf("WiFi Soft AP Consumers: %d", networkConsumerCountBits(networkSoftApConsumer));
20242045
networkConsumerPrint(networkSoftApConsumer, 0, ", ");
20252046
systemPrintln();
20262047
}
@@ -2279,10 +2300,7 @@ void networkStartDelayed(NetIndex_t index, uintptr_t parameter, bool debug)
22792300
//----------------------------------------
22802301
void networkUpdate()
22812302
{
2282-
bool displayIpAddress;
22832303
NetIndex_t index;
2284-
IPAddress ipAddress;
2285-
bool ipAddressDisplayed;
22862304
uint8_t networkType;
22872305
NETWORK_POLL_ROUTINE pollRoutine;
22882306
uint8_t priority;
@@ -2295,18 +2313,8 @@ void networkUpdate()
22952313

22962314
// Handle the network lost internet event
22972315
if (networkEventInternetLost[index])
2298-
{
22992316
networkInterfaceInternetConnectionLost(index);
23002317

2301-
// Attempt to restart WiFi
2302-
if ((index == NETWORK_WIFI_STATION) && (networkIsHighestPriority(index)))
2303-
{
2304-
if (networkIsStarted(index))
2305-
networkStop(index, settings.debugWifiState, __FILE__, __LINE__);
2306-
networkStart(index, settings.debugWifiState, __FILE__, __LINE__);
2307-
}
2308-
}
2309-
23102318
// Handle the network stop event
23112319
if (networkEventStop[index])
23122320
networkStop(index, settings.debugNetworkLayer, __FILE__, __LINE__);
@@ -2341,6 +2349,9 @@ void networkUpdate()
23412349
}
23422350
}
23432351

2352+
// Update the WiFi state
2353+
wifiStationUpdate();
2354+
23442355
// Update the network services
23452356
// Start or stop mDNS
23462357
if (networkMdnsRequests != networkMdnsRunning)
@@ -2367,44 +2378,62 @@ void networkUpdate()
23672378
webServerUpdate(); // Start webServer for web config as needed
23682379

23692380
// Periodically display the network interface state
2370-
displayIpAddress = PERIODIC_DISPLAY(PD_IP_ADDRESS);
2371-
for (int index = 0; index < NETWORK_OFFLINE; index++)
2381+
if (PERIODIC_DISPLAY(PD_NETWORK_STATE))
23722382
{
2373-
// Display the current state
2374-
ipAddressDisplayed = displayIpAddress && (index == networkPriority);
2375-
if (PERIODIC_DISPLAY(networkInterfaceTable[index].pdState) || PERIODIC_DISPLAY(PD_NETWORK_STATE) ||
2376-
ipAddressDisplayed)
2377-
{
2383+
PERIODIC_CLEAR(PD_NETWORK_STATE);
2384+
PERIODIC_CLEAR(PD_IP_ADDRESS);
2385+
for (int index = 0; index < NETWORK_OFFLINE; index++)
23782386
PERIODIC_CLEAR(networkInterfaceTable[index].pdState);
2379-
if (networkInterfaceTable[index].netif->hasIP())
2380-
{
2381-
ipAddress = networkInterfaceTable[index].netif->localIP();
2382-
systemPrintf("%s: %s%s\r\n", networkInterfaceTable[index].name, ipAddress.toString().c_str(),
2383-
networkInterfaceTable[index].netif->isDefault() ? " (default)" : "");
2384-
}
2385-
else if (networkInterfaceTable[index].netif->linkUp())
2386-
systemPrintf("%s: Link Up\r\n", networkInterfaceTable[index].name);
2387-
else if (networkInterfaceTable[index].netif->started())
2388-
systemPrintf("%s: Started\r\n", networkInterfaceTable[index].name);
23892387

2390-
else if (index == NETWORK_WIFI_STATION && (WiFi.getMode() == WIFI_AP || WiFi.getMode() == WIFI_AP_STA))
2391-
{
2392-
// NETIF doesn't capture the IP address of a soft AP
2393-
ipAddress = WiFi.softAPIP();
2394-
systemPrintf("%s: %s%s\r\n", networkInterfaceTable[index].name, ipAddress.toString().c_str(),
2395-
networkInterfaceTable[index].netif->isDefault() ? " (default)" : "");
2396-
}
2397-
else
2398-
systemPrintf("%s: Stopped\r\n", networkInterfaceTable[index].name);
2399-
}
2388+
// Display the network state
2389+
networkDisplayStatus();
24002390
}
2401-
if (PERIODIC_DISPLAY(PD_NETWORK_STATE))
2402-
PERIODIC_CLEAR(PD_NETWORK_STATE);
2403-
if (displayIpAddress)
2391+
2392+
// Periodically display the IP address
2393+
else if (PERIODIC_DISPLAY(PD_IP_ADDRESS))
24042394
{
2405-
if (!ipAddressDisplayed)
2406-
systemPrintln("Network: Offline");
2395+
int index;
2396+
IPAddress ipAddress;
2397+
24072398
PERIODIC_CLEAR(PD_IP_ADDRESS);
2399+
2400+
// Display the IP address of the highest priority network
2401+
index = networkPriorityTable[networkPriority];
2402+
if ((index < NETWORK_OFFLINE)
2403+
&& networkInterfaceHasInternet(index)
2404+
&& networkInterfaceTable[index].netif->hasIP())
2405+
{
2406+
ipAddress = networkInterfaceTable[index].netif->localIP();
2407+
systemPrintf("%s: %s%s\r\n",
2408+
networkInterfaceTable[index].name,
2409+
ipAddress.toString().c_str(),
2410+
networkInterfaceTable[index].netif->isDefault() ? " (default)" : "");
2411+
}
2412+
else
2413+
systemPrintf("Network: Offline\r\n");
2414+
2415+
// Display the soft AP IP address
2416+
if (wifiSoftApOnline)
2417+
{
2418+
ipAddress = wifiSoftApGetIpAddress();
2419+
systemPrintf("WiFi Soft AP: %s\r\n", ipAddress.toString().c_str());
2420+
}
2421+
else
2422+
systemPrintf("WiFi Soft AP: Offline\r\n");
2423+
}
2424+
2425+
// Periodically display an interface state
2426+
else
2427+
{
2428+
for (int index = 0; index < NETWORK_OFFLINE; index++)
2429+
if (PERIODIC_DISPLAY(networkInterfaceTable[index].pdState))
2430+
{
2431+
PERIODIC_CLEAR(networkInterfaceTable[index].pdState);
2432+
2433+
// Display the state for an interface
2434+
networkPrintStatus(index);
2435+
networkDisplayInterface(index);
2436+
}
24082437
}
24092438
}
24102439

@@ -2437,6 +2466,26 @@ void networkUserAdd(NETCONSUMER_t consumer, const char *fileName, uint32_t lineN
24372466
networkConsumerIndexLast[consumer] = index;
24382467
}
24392468

2469+
//----------------------------------------
2470+
// Get the network user bit mask
2471+
//----------------------------------------
2472+
NETCONSUMER_MASK_t networkUserBits(NetIndex_t index)
2473+
{
2474+
// Validate the index
2475+
networkValidateIndex(index);
2476+
2477+
// Return the consumer bits
2478+
return netIfUsers[index];
2479+
}
2480+
2481+
//----------------------------------------
2482+
// Count the number of network users
2483+
//----------------------------------------
2484+
int networkUserCount(NetIndex_t index)
2485+
{
2486+
return networkConsumerCountBits(networkUserBits(index));
2487+
}
2488+
24402489
//----------------------------------------
24412490
// Display the network interface users
24422491
//----------------------------------------
@@ -2449,7 +2498,7 @@ void networkUserDisplay(NetIndex_t index)
24492498

24502499
// Determine if there are any users
24512500
bits = netIfUsers[index];
2452-
systemPrintf("%s Users: %d", networkInterfaceTable[index].name, networkConsumerCount(bits));
2501+
systemPrintf("%s Users: %d", networkInterfaceTable[index].name, networkConsumerCountBits(bits));
24532502
networkConsumerPrint(bits, 0, ", ");
24542503
systemPrintln();
24552504
}

0 commit comments

Comments
 (0)