@@ -103,22 +103,10 @@ Network.ino
103
103
// Constants
104
104
// ----------------------------------------
105
105
106
- static const char * networkConsumerTable[] =
107
- {
108
- " HTTP_CLIENT" ,
109
- " NTP_SERVER" ,
110
- " NTRIP_CLIENT" ,
111
- " NTRIP_SERVER_0" ,
112
- " NTRIP_SERVER_1" ,
113
- " NTRIP_SERVER_2" ,
114
- " NTRIP_SERVER_3" ,
115
- " OTA_CLIENT" ,
116
- " PPL_KEY_UPDATE" ,
117
- " PPL_MQTT_CLIENT" ,
118
- " TCP_CLIENT" ,
119
- " TCP_SERVER" ,
120
- " UDP_SERVER" ,
121
- " WEB_CONFIG" ,
106
+ static const char *networkConsumerTable[] = {
107
+ " HTTP_CLIENT" , " NTP_SERVER" , " NTRIP_CLIENT" , " NTRIP_SERVER_0" , " NTRIP_SERVER_1" ,
108
+ " NTRIP_SERVER_2" , " NTRIP_SERVER_3" , " OTA_CLIENT" , " PPL_KEY_UPDATE" , " PPL_MQTT_CLIENT" ,
109
+ " TCP_CLIENT" , " TCP_SERVER" , " UDP_SERVER" , " WEB_CONFIG" ,
122
110
};
123
111
124
112
static const int networkConsumerTableEntries = sizeof (networkConsumerTable) / sizeof (networkConsumerTable[0 ]);
@@ -128,8 +116,8 @@ static const int networkConsumerTableEntries = sizeof(networkConsumerTable) / si
128
116
// ----------------------------------------
129
117
130
118
NETCONSUMER_MASK_t netIfConsumers[NETWORK_MAX]; // Consumers of a specific network
131
- NETCONSUMER_MASK_t networkConsumersAny; // Consumers of any network
132
- NETCONSUMER_MASK_t networkSoftApConsumer; // Consumers of soft AP
119
+ NETCONSUMER_MASK_t networkConsumersAny; // Consumers of any network
120
+ NETCONSUMER_MASK_t networkSoftApConsumer; // Consumers of soft AP
133
121
134
122
// Priority of the network when last checked by the consumer
135
123
// Index by consumer ID
@@ -173,7 +161,7 @@ NetMask_t networkStarted; // Track the running networks
173
161
NETWORK_POLL_SEQUENCE *networkSequence[NETWORK_OFFLINE];
174
162
175
163
NetMask_t networkMdnsRequests; // Non-zero when one or more interfaces request mDNS
176
- NetMask_t networkMdnsRunning; // Non-zero when mDNS is running
164
+ NetMask_t networkMdnsRunning; // Non-zero when mDNS is running
177
165
178
166
// ----------------------------------------
179
167
// Menu for configuring TCP/UDP interfaces
@@ -380,8 +368,8 @@ bool networkChanged(NETCONSUMER_t consumer)
380
368
networkConsumerValidate (consumer);
381
369
382
370
// Determine if the network interface has changed
383
- changed = (networkConsumerPriority[consumer] != NETWORK_OFFLINE)
384
- && (networkConsumerPriority[consumer] != networkConsumerPriorityLast[consumer]);
371
+ changed = (networkConsumerPriority[consumer] != NETWORK_OFFLINE) &&
372
+ (networkConsumerPriority[consumer] != networkConsumerPriorityLast[consumer]);
385
373
386
374
// Remember the new network
387
375
if (changed)
@@ -392,16 +380,13 @@ bool networkChanged(NETCONSUMER_t consumer)
392
380
// ----------------------------------------
393
381
// Add a network consumer
394
382
// ----------------------------------------
395
- void networkConsumerAdd (NETCONSUMER_t consumer,
396
- NetIndex_t network,
397
- const char * fileName,
398
- uint32_t lineNumber)
383
+ void networkConsumerAdd (NETCONSUMER_t consumer, NetIndex_t network, const char *fileName, uint32_t lineNumber)
399
384
{
400
385
NETCONSUMER_MASK_t bitMask;
401
- NETCONSUMER_MASK_t * bits;
386
+ NETCONSUMER_MASK_t *bits;
402
387
NETCONSUMER_MASK_t consumers;
403
388
NetIndex_t index;
404
- const char * networkName;
389
+ const char *networkName;
405
390
NETCONSUMER_MASK_t previousBits;
406
391
NetPriority_t priority;
407
392
@@ -486,8 +471,7 @@ void networkConsumerAdd(NETCONSUMER_t consumer,
486
471
}
487
472
else
488
473
{
489
- systemPrintf (" Network consumer %s added more than once\r\n " ,
490
- networkConsumerTable[consumer]);
474
+ systemPrintf (" Network consumer %s added more than once\r\n " , networkConsumerTable[consumer]);
491
475
reportFatalError (" Network consumer added more than once!" );
492
476
}
493
477
}
@@ -598,9 +582,7 @@ void networkConsumerOffline(NETCONSUMER_t consumer)
598
582
// ----------------------------------------
599
583
// Print the list of consumers
600
584
// ----------------------------------------
601
- void networkConsumerPrint (NETCONSUMER_MASK_t consumers,
602
- NETCONSUMER_MASK_t users,
603
- const char * separation)
585
+ void networkConsumerPrint (NETCONSUMER_MASK_t consumers, NETCONSUMER_MASK_t users, const char *separation)
604
586
{
605
587
NETCONSUMER_MASK_t consumerMask;
606
588
@@ -609,7 +591,7 @@ void networkConsumerPrint(NETCONSUMER_MASK_t consumers,
609
591
consumerMask = 1 << consumer;
610
592
if (consumers & consumerMask)
611
593
{
612
- const char * active = (users & consumerMask) ? " *" : " " ;
594
+ const char *active = (users & consumerMask) ? " *" : " " ;
613
595
systemPrintf (" %s%s%s" , separation, active, networkConsumerTable[consumer]);
614
596
separation = " , " ;
615
597
}
@@ -627,8 +609,7 @@ void networkConsumerReconnect(NetIndex_t index)
627
609
628
610
// Determine the consumers of the network
629
611
consumers = netIfConsumers[index];
630
- if ((networkPriority < NETWORK_OFFLINE)
631
- && (networkIndexTable[networkPriority] == index))
612
+ if ((networkPriority < NETWORK_OFFLINE) && (networkIndexTable[networkPriority] == index))
632
613
{
633
614
consumers |= networkConsumersAny;
634
615
}
@@ -645,16 +626,13 @@ void networkConsumerReconnect(NetIndex_t index)
645
626
// ----------------------------------------
646
627
// Remove a network consumer
647
628
// ----------------------------------------
648
- void networkConsumerRemove (NETCONSUMER_t consumer,
649
- NetIndex_t network,
650
- const char * fileName,
651
- uint32_t lineNumber)
629
+ void networkConsumerRemove (NETCONSUMER_t consumer, NetIndex_t network, const char *fileName, uint32_t lineNumber)
652
630
{
653
631
NETCONSUMER_MASK_t bitMask;
654
- NETCONSUMER_MASK_t * bits;
632
+ NETCONSUMER_MASK_t *bits;
655
633
NETCONSUMER_MASK_t consumers;
656
634
NetIndex_t index;
657
- const char * networkName;
635
+ const char *networkName;
658
636
NETCONSUMER_MASK_t previousBits;
659
637
int priority;
660
638
@@ -1135,9 +1113,7 @@ void networkInterfaceEventInternetAvailable(NetIndex_t index)
1135
1113
// ----------------------------------------
1136
1114
// Internet lost event
1137
1115
// ----------------------------------------
1138
- void networkInterfaceEventInternetLost (NetIndex_t index,
1139
- const char * fileName,
1140
- uint32_t lineNumber)
1116
+ void networkInterfaceEventInternetLost (NetIndex_t index, const char *fileName, uint32_t lineNumber)
1141
1117
{
1142
1118
// Validate the index
1143
1119
networkValidateIndex (index);
@@ -1597,8 +1573,7 @@ void networkPrintStatus(uint8_t priority)
1597
1573
}
1598
1574
1599
1575
// Print the network interface status
1600
- systemPrintf (" %c%d: %-10s %s" ,
1601
- highestPriority ? ' *' : ' ' , priority, name, status);
1576
+ systemPrintf (" %c%d: %-10s %s" , highestPriority ? ' *' : ' ' , priority, name, status);
1602
1577
1603
1578
// Display more data about the highest priority network
1604
1579
if (highestPriority)
@@ -1660,10 +1635,7 @@ void networkSequenceBoot(NetIndex_t index)
1660
1635
// ----------------------------------------
1661
1636
// Exit the sequence by force
1662
1637
// ----------------------------------------
1663
- void networkSequenceExit (NetIndex_t index,
1664
- bool debug,
1665
- const char * fileName,
1666
- uint32_t lineNumber)
1638
+ void networkSequenceExit (NetIndex_t index, bool debug, const char *fileName, uint32_t lineNumber)
1667
1639
{
1668
1640
// Display the call
1669
1641
if (settings.debugNetworkLayer )
@@ -1733,10 +1705,7 @@ void networkSequenceNextEntry(NetIndex_t index, bool debug)
1733
1705
// ----------------------------------------
1734
1706
// Attempt to start the start sequence
1735
1707
// ----------------------------------------
1736
- void networkSequenceStart (NetIndex_t index,
1737
- bool debug,
1738
- const char * fileName,
1739
- uint32_t lineNumber)
1708
+ void networkSequenceStart (NetIndex_t index, bool debug, const char *fileName, uint32_t lineNumber)
1740
1709
{
1741
1710
NetMask_t bitMask;
1742
1711
const char *description;
@@ -1820,10 +1789,7 @@ void networkSequenceStart(NetIndex_t index,
1820
1789
// ----------------------------------------
1821
1790
// Start the stop sequence
1822
1791
// ----------------------------------------
1823
- void networkSequenceStop (NetIndex_t index,
1824
- bool debug,
1825
- const char * fileName,
1826
- uint32_t lineNumber)
1792
+ void networkSequenceStop (NetIndex_t index, bool debug, const char *fileName, uint32_t lineNumber)
1827
1793
{
1828
1794
NetMask_t bitMask;
1829
1795
const char *description;
@@ -1906,10 +1872,7 @@ void networkSequenceStop(NetIndex_t index,
1906
1872
// ----------------------------------------
1907
1873
// Stop the polling sequence
1908
1874
// ----------------------------------------
1909
- void networkSequenceStopPolling (NetIndex_t index,
1910
- bool debug,
1911
- bool forcedStop,
1912
- const char * fileName,
1875
+ void networkSequenceStopPolling (NetIndex_t index, bool debug, bool forcedStop, const char *fileName,
1913
1876
uint32_t lineNumber)
1914
1877
{
1915
1878
NetMask_t bitMask;
@@ -1920,12 +1883,10 @@ void networkSequenceStopPolling(NetIndex_t index,
1920
1883
1921
1884
// Display the call
1922
1885
if (settings.debugNetworkLayer )
1923
- systemPrintf (" Network: Calling networkSequenceStopPolling(%s, debug: %s, forcedStop: %s) from %s at line %d\r\n " ,
1924
- networkInterfaceTable[index].name ,
1925
- debug ? " true" : " false" ,
1926
- forcedStop ? " true" : " false" ,
1927
- fileName,
1928
- lineNumber);
1886
+ systemPrintf (
1887
+ " Network: Calling networkSequenceStopPolling(%s, debug: %s, forcedStop: %s) from %s at line %d\r\n " ,
1888
+ networkInterfaceTable[index].name , debug ? " true" : " false" , forcedStop ? " true" : " false" , fileName,
1889
+ lineNumber);
1929
1890
1930
1891
// Stop the polling for this sequence
1931
1892
networkSequence[index] = nullptr ;
@@ -1999,9 +1960,7 @@ void networkSequenceStopPolling(NetIndex_t index,
1999
1960
// ----------------------------------------
2000
1961
// Add a soft AP consumer
2001
1962
// ----------------------------------------
2002
- void networkSoftApConsumerAdd (NETCONSUMER_t consumer,
2003
- const char * fileName,
2004
- uint32_t lineNumber)
1963
+ void networkSoftApConsumerAdd (NETCONSUMER_t consumer, const char *fileName, uint32_t lineNumber)
2005
1964
{
2006
1965
NETCONSUMER_MASK_t bitMask;
2007
1966
NetIndex_t index;
@@ -2012,8 +1971,7 @@ void networkSoftApConsumerAdd(NETCONSUMER_t consumer,
2012
1971
2013
1972
// Display the call
2014
1973
if (settings.debugNetworkLayer )
2015
- systemPrintf (" Network: Calling networkSoftApConsumerAdd from %s at line %d\r\n " ,
2016
- fileName, lineNumber);
1974
+ systemPrintf (" Network: Calling networkSoftApConsumerAdd from %s at line %d\r\n " , fileName, lineNumber);
2017
1975
2018
1976
// Add this consumer only once
2019
1977
bitMask = 1 << consumer;
@@ -2041,8 +1999,7 @@ void networkSoftApConsumerAdd(NETCONSUMER_t consumer,
2041
1999
}
2042
2000
else
2043
2001
{
2044
- systemPrintf (" Network: Soft AP consumer %s added more than once!\r\n " ,
2045
- networkConsumerTable[consumer]);
2002
+ systemPrintf (" Network: Soft AP consumer %s added more than once!\r\n " , networkConsumerTable[consumer]);
2046
2003
reportFatalError (" Network: Soft AP consumer added more than once!" );
2047
2004
}
2048
2005
}
@@ -2068,7 +2025,7 @@ void networkSoftApConsumerDisplay()
2068
2025
// ----------------------------------------
2069
2026
// Print the soft AP consumers
2070
2027
// ----------------------------------------
2071
- void networkSoftApConsumerPrint (const char * separator)
2028
+ void networkSoftApConsumerPrint (const char *separator)
2072
2029
{
2073
2030
NETCONSUMER_MASK_t consumerMask;
2074
2031
@@ -2087,9 +2044,7 @@ void networkSoftApConsumerPrint(const char * separator)
2087
2044
// ----------------------------------------
2088
2045
// Remove a soft AP consumer
2089
2046
// ----------------------------------------
2090
- void networkSoftApConsumerRemove (NETCONSUMER_t consumer,
2091
- const char * fileName,
2092
- uint32_t lineNumber)
2047
+ void networkSoftApConsumerRemove (NETCONSUMER_t consumer, const char *fileName, uint32_t lineNumber)
2093
2048
{
2094
2049
NETCONSUMER_MASK_t bitMask;
2095
2050
NetIndex_t index;
@@ -2100,8 +2055,7 @@ void networkSoftApConsumerRemove(NETCONSUMER_t consumer,
2100
2055
2101
2056
// Display the call
2102
2057
if (settings.debugNetworkLayer )
2103
- systemPrintf (" Network: Calling networkSoftApConsumerRemove from %s at line %d\r\n " ,
2104
- fileName, lineNumber);
2058
+ systemPrintf (" Network: Calling networkSoftApConsumerRemove from %s at line %d\r\n " , fileName, lineNumber);
2105
2059
2106
2060
// Remove the consumer only once
2107
2061
bitMask = 1 << consumer;
@@ -2138,10 +2092,7 @@ void networkSoftApConsumerRemove(NETCONSUMER_t consumer,
2138
2092
// ----------------------------------------
2139
2093
// Start a network interface
2140
2094
// ----------------------------------------
2141
- void networkStart (NetIndex_t index,
2142
- bool debug,
2143
- const char * fileName,
2144
- uint32_t lineNumber)
2095
+ void networkStart (NetIndex_t index, bool debug, const char *fileName, uint32_t lineNumber)
2145
2096
{
2146
2097
NETCONSUMER_MASK_t consumers;
2147
2098
@@ -2152,8 +2103,8 @@ void networkStart(NetIndex_t index,
2152
2103
if (settings.debugNetworkLayer )
2153
2104
{
2154
2105
networkDisplayStatus ();
2155
- systemPrintf (" Network: Calling networkStart(%s) from %s at line %d\r\n " ,
2156
- networkInterfaceTable[index]. name , fileName, lineNumber);
2106
+ systemPrintf (" Network: Calling networkStart(%s) from %s at line %d\r\n " , networkInterfaceTable[index]. name ,
2107
+ fileName, lineNumber);
2157
2108
}
2158
2109
2159
2110
// Only start networks that exist on the platform
@@ -2219,10 +2170,7 @@ void networkStartNextInterface(NetIndex_t index)
2219
2170
// ----------------------------------------
2220
2171
// Stop a network interface
2221
2172
// ----------------------------------------
2222
- void networkStop (NetIndex_t index,
2223
- bool debug,
2224
- const char * fileName,
2225
- uint32_t lineNumber)
2173
+ void networkStop (NetIndex_t index, bool debug, const char *fileName, uint32_t lineNumber)
2226
2174
{
2227
2175
NetMask_t bitMask;
2228
2176
@@ -2232,8 +2180,8 @@ void networkStop(NetIndex_t index,
2232
2180
// Display the call
2233
2181
if (settings.debugNetworkLayer )
2234
2182
{
2235
- systemPrintf (" Network: Calling networkStop(%s) from %s at line %d\r\n " ,
2236
- networkInterfaceTable[index]. name , fileName, lineNumber);
2183
+ systemPrintf (" Network: Calling networkStop(%s) from %s at line %d\r\n " , networkInterfaceTable[index]. name ,
2184
+ fileName, lineNumber);
2237
2185
networkDisplayStatus ();
2238
2186
}
2239
2187
@@ -2427,14 +2375,11 @@ void networkUpdate()
2427
2375
2428
2376
// Display the IP address of the highest priority network
2429
2377
index = networkPriorityTable[networkPriority];
2430
- if ((index < NETWORK_OFFLINE)
2431
- && networkInterfaceHasInternet (index)
2432
- && networkInterfaceTable[index].netif ->hasIP ())
2378
+ if ((index < NETWORK_OFFLINE) && networkInterfaceHasInternet (index) &&
2379
+ networkInterfaceTable[index].netif ->hasIP ())
2433
2380
{
2434
2381
ipAddress = networkInterfaceTable[index].netif ->localIP ();
2435
- systemPrintf (" %s: %s%s\r\n " ,
2436
- networkInterfaceTable[index].name ,
2437
- ipAddress.toString ().c_str (),
2382
+ systemPrintf (" %s: %s%s\r\n " , networkInterfaceTable[index].name , ipAddress.toString ().c_str (),
2438
2383
networkInterfaceTable[index].netif ->isDefault () ? " (default)" : " " );
2439
2384
}
2440
2385
else
@@ -2468,18 +2413,16 @@ void networkUpdate()
2468
2413
// ----------------------------------------
2469
2414
// Add a network user
2470
2415
// ----------------------------------------
2471
- void networkUserAdd (NETCONSUMER_t consumer,
2472
- const char * fileName,
2473
- uint32_t lineNumber)
2416
+ void networkUserAdd (NETCONSUMER_t consumer, const char *fileName, uint32_t lineNumber)
2474
2417
{
2475
2418
NetIndex_t index;
2476
2419
NETCONSUMER_MASK_t mask;
2477
2420
2478
2421
// Validate the consumer
2479
2422
networkConsumerValidate (consumer);
2480
2423
if (settings.debugNetworkLayer )
2481
- systemPrintf (" Network: Calling networkUserAdd(%s) from %s at line %d\r\n " ,
2482
- networkConsumerTable[consumer], fileName, lineNumber);
2424
+ systemPrintf (" Network: Calling networkUserAdd(%s) from %s at line %d\r\n " , networkConsumerTable[consumer],
2425
+ fileName, lineNumber);
2483
2426
2484
2427
// Convert the priority into a network interface index
2485
2428
index = networkIndexTable[networkPriority];
@@ -2536,18 +2479,16 @@ void networkUserDisplay(NetIndex_t index)
2536
2479
// ----------------------------------------
2537
2480
// Remove a network user
2538
2481
// ----------------------------------------
2539
- void networkUserRemove (NETCONSUMER_t consumer,
2540
- const char * fileName,
2541
- uint32_t lineNumber)
2482
+ void networkUserRemove (NETCONSUMER_t consumer, const char *fileName, uint32_t lineNumber)
2542
2483
{
2543
2484
NetIndex_t index;
2544
2485
NETCONSUMER_MASK_t mask;
2545
2486
2546
2487
// Validate the consumer
2547
2488
networkConsumerValidate (consumer);
2548
2489
if (settings.debugNetworkLayer )
2549
- systemPrintf (" Network: Calling networkUserRemove(%s) from %s at line %d\r\n " ,
2550
- networkConsumerTable[consumer], fileName, lineNumber);
2490
+ systemPrintf (" Network: Calling networkUserRemove(%s) from %s at line %d\r\n " , networkConsumerTable[consumer],
2491
+ fileName, lineNumber);
2551
2492
2552
2493
// Convert the priority into a network interface index
2553
2494
index = networkConsumerIndexLast[consumer];
0 commit comments