Skip to content

Commit b4deab9

Browse files
authored
Merge pull request #626 from LeeLeahy2/logging
Network: Add fileName and lineNumber to various calls
2 parents c776d82 + 0deb516 commit b4deab9

File tree

4 files changed

+78
-27
lines changed

4 files changed

+78
-27
lines changed

Firmware/RTK_Everywhere/Cellular.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void cellularEvent(arduino_event_id_t event)
8787
if (networkInterfaceHasInternet(NETWORK_CELLULAR) && (event != ARDUINO_EVENT_ETH_GOT_IP) &&
8888
(event != ARDUINO_EVENT_ETH_GOT_IP6) && (event != ARDUINO_EVENT_PPP_CONNECTED))
8989
{
90-
networkInterfaceEventInternetLost(NETWORK_CELLULAR);
90+
networkInterfaceEventInternetLost(NETWORK_CELLULAR, __FILE__, __LINE__);
9191
}
9292

9393
// Cellular State Machine
@@ -157,7 +157,7 @@ void cellularSimCheck(NetIndex_t index, uintptr_t parameter, bool debug)
157157
{
158158
systemPrintf("SIM card not present. Marking cellular offline.\r\n");
159159
present.cellular_lara = false;
160-
networkSequenceExit(index, debug);
160+
networkSequenceExit(index, debug, __FILE__, __LINE__);
161161
}
162162
}
163163

Firmware/RTK_Everywhere/Ethernet.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ void ethernetEvent(arduino_event_id_t event, arduino_event_info_t info)
199199
// Take the network offline if necessary
200200
if (event != ARDUINO_EVENT_ETH_GOT_IP)
201201
{
202-
networkInterfaceEventInternetLost((NetIndex_t)NETWORK_ETHERNET);
202+
networkInterfaceEventInternetLost((NetIndex_t)NETWORK_ETHERNET, __FILE__, __LINE__);
203203
}
204204
}
205205

Firmware/RTK_Everywhere/Network.ino

+66-15
Original file line numberDiff line numberDiff line change
@@ -1070,11 +1070,18 @@ void networkInterfaceEventInternetAvailable(NetIndex_t index)
10701070
//----------------------------------------
10711071
// Internet lost event
10721072
//----------------------------------------
1073-
void networkInterfaceEventInternetLost(NetIndex_t index)
1073+
void networkInterfaceEventInternetLost(NetIndex_t index,
1074+
const char * fileName,
1075+
uint32_t lineNumber)
10741076
{
10751077
// Validate the index
10761078
networkValidateIndex(index);
10771079

1080+
// Display the call
1081+
if (settings.debugNetworkLayer)
1082+
systemPrintf("Network: Calling networkInterfaceEventInternetLost(%s) from %s at line %d\r\n",
1083+
networkInterfaceTable[index].name, fileName, lineNumber);
1084+
10781085
// Notify networkUpdate of the change in state
10791086
if (settings.debugNetworkLayer)
10801087
systemPrintf("%s lost internet access event\r\n", networkInterfaceTable[index].name);
@@ -1178,7 +1185,7 @@ void networkInterfaceInternetConnectionAvailable(NetIndex_t index)
11781185
{
11791186
// Stop the previous network
11801187
systemPrintf("Stopping %s\r\n", networkGetNameByIndex(index));
1181-
networkSequenceStop(index, settings.debugNetworkLayer);
1188+
networkSequenceStop(index, settings.debugNetworkLayer, __FILE__, __LINE__);
11821189
}
11831190
}
11841191

@@ -1195,7 +1202,9 @@ void networkInterfaceInternetConnectionAvailable(NetIndex_t index)
11951202
//----------------------------------------
11961203
// Mark network interface as having NO access to the internet
11971204
//----------------------------------------
1198-
void networkInterfaceInternetConnectionLost(NetIndex_t index)
1205+
void networkInterfaceInternetConnectionLost(NetIndex_t index,
1206+
const char * fileName,
1207+
uint32_t lineNumber)
11991208
{
12001209
NetMask_t bitMask;
12011210
NetPriority_t previousPriority;
@@ -1204,6 +1213,11 @@ void networkInterfaceInternetConnectionLost(NetIndex_t index)
12041213
// Validate the index
12051214
networkValidateIndex(index);
12061215

1216+
// Display the call
1217+
if (settings.debugNetworkLayer)
1218+
systemPrintf("Network: Calling networkInterfaceInternetConnectionLost(%s) from %s at line %d\r\n",
1219+
networkInterfaceTable[index].name, fileName, lineNumber);
1220+
12071221
// Clear the event flag
12081222
networkEventInternetLost[index] = false;
12091223

@@ -1562,10 +1576,18 @@ void networkSequenceBoot(NetIndex_t index)
15621576
//----------------------------------------
15631577
// Exit the sequence by force
15641578
//----------------------------------------
1565-
void networkSequenceExit(NetIndex_t index, bool debug)
1579+
void networkSequenceExit(NetIndex_t index,
1580+
bool debug,
1581+
const char * fileName,
1582+
uint32_t lineNumber)
15661583
{
1584+
// Display the call
1585+
if (settings.debugNetworkLayer)
1586+
systemPrintf("Network: Calling networkSequenceExit(%s) from %s at line %d\r\n",
1587+
networkInterfaceTable[index].name, fileName, lineNumber);
1588+
15671589
// Stop the polling for this sequence
1568-
networkSequenceStopPolling(index, debug, true);
1590+
networkSequenceStopPolling(index, debug, true, __FILE__, __LINE__);
15691591
}
15701592

15711593
//----------------------------------------
@@ -1621,13 +1643,16 @@ void networkSequenceNextEntry(NetIndex_t index, bool debug)
16211643

16221644
// Termination entry found, stop the sequence or start next sequence
16231645
else
1624-
networkSequenceStopPolling(index, debug, false);
1646+
networkSequenceStopPolling(index, debug, false, __FILE__, __LINE__);
16251647
}
16261648

16271649
//----------------------------------------
16281650
// Attempt to start the start sequence
16291651
//----------------------------------------
1630-
void networkSequenceStart(NetIndex_t index, bool debug)
1652+
void networkSequenceStart(NetIndex_t index,
1653+
bool debug,
1654+
const char * fileName,
1655+
uint32_t lineNumber)
16311656
{
16321657
NetMask_t bitMask;
16331658
const char *description;
@@ -1636,6 +1661,11 @@ void networkSequenceStart(NetIndex_t index, bool debug)
16361661
// Validate the index
16371662
networkValidateIndex(index);
16381663

1664+
// Display the call
1665+
if (settings.debugNetworkLayer)
1666+
systemPrintf("Network: Calling networkSequenceStart(%s) from %s at line %d\r\n",
1667+
networkInterfaceTable[index].name, fileName, lineNumber);
1668+
16391669
// Set the network bit
16401670
bitMask = 1 << index;
16411671

@@ -1706,7 +1736,10 @@ void networkSequenceStart(NetIndex_t index, bool debug)
17061736
//----------------------------------------
17071737
// Start the stop sequence
17081738
//----------------------------------------
1709-
void networkSequenceStop(NetIndex_t index, bool debug)
1739+
void networkSequenceStop(NetIndex_t index,
1740+
bool debug,
1741+
const char * fileName,
1742+
uint32_t lineNumber)
17101743
{
17111744
NetMask_t bitMask;
17121745
const char *description;
@@ -1715,6 +1748,11 @@ void networkSequenceStop(NetIndex_t index, bool debug)
17151748
// Validate the index
17161749
networkValidateIndex(index);
17171750

1751+
// Display the call
1752+
if (settings.debugNetworkLayer)
1753+
systemPrintf("Network: Calling networkSequenceStop(%s) from %s at line %d\r\n",
1754+
networkInterfaceTable[index].name, fileName, lineNumber);
1755+
17181756
// Set the network bit
17191757
bitMask = 1 << index;
17201758

@@ -1784,14 +1822,27 @@ void networkSequenceStop(NetIndex_t index, bool debug)
17841822
//----------------------------------------
17851823
// Stop the polling sequence
17861824
//----------------------------------------
1787-
void networkSequenceStopPolling(NetIndex_t index, bool debug, bool forcedStop)
1825+
void networkSequenceStopPolling(NetIndex_t index,
1826+
bool debug,
1827+
bool forcedStop,
1828+
const char * fileName,
1829+
uint32_t lineNumber)
17881830
{
17891831
NetMask_t bitMask;
17901832
bool start;
17911833

17921834
// Validate the index
17931835
networkValidateIndex(index);
17941836

1837+
// Display the call
1838+
if (settings.debugNetworkLayer)
1839+
systemPrintf("Network: Calling networkSequenceStopPolling(%s, debug: %s, forcedStop: %s) from %s at line %d\r\n",
1840+
networkInterfaceTable[index].name,
1841+
debug ? "true" : "false",
1842+
forcedStop ? "true" : "false",
1843+
fileName,
1844+
lineNumber);
1845+
17951846
// Stop the polling for this sequence
17961847
networkSequence[index] = nullptr;
17971848
bitMask = 1 << index;
@@ -1855,9 +1906,9 @@ void networkSequenceStopPolling(NetIndex_t index, bool debug, bool forcedStop)
18551906

18561907
// Start the next sequence
18571908
if (start)
1858-
networkSequenceStart(index, debug);
1909+
networkSequenceStart(index, debug, __FILE__, __LINE__);
18591910
else
1860-
networkSequenceStop(index, debug);
1911+
networkSequenceStop(index, debug, __FILE__, __LINE__);
18611912
}
18621913
}
18631914

@@ -2017,7 +2068,7 @@ void networkStart(NetIndex_t index, bool debug, const char * fileName, uint32_t
20172068
{
20182069
if (debug)
20192070
systemPrintf("Starting network: %s\r\n", networkGetNameByIndex(index));
2020-
networkSequenceStart(index, debug);
2071+
networkSequenceStart(index, debug, __FILE__, __LINE__);
20212072
}
20222073
}
20232074
else if (debug)
@@ -2098,7 +2149,7 @@ void networkStop(NetIndex_t index, bool debug, const char * fileName, uint32_t l
20982149
{
20992150
if (debug)
21002151
systemPrintf("Stopping network: %s\r\n", networkGetNameByIndex(index));
2101-
networkSequenceStop(index, debug);
2152+
networkSequenceStop(index, debug, __FILE__, __LINE__);
21022153
}
21032154
}
21042155
}
@@ -2192,7 +2243,7 @@ void networkUpdate()
21922243
// Handle the network lost internet event
21932244
if (networkEventInternetLost[index])
21942245
{
2195-
networkInterfaceInternetConnectionLost(index);
2246+
networkInterfaceInternetConnectionLost(index, __FILE__, __LINE__);
21962247

21972248
// Attempt to restart WiFi
21982249
if ((index == NETWORK_WIFI_STATION) && (networkIsHighestPriority(index)))
@@ -2441,7 +2492,7 @@ void networkVerifyPriority(NetIndex_t index, uintptr_t parameter, bool debug)
24412492
if (debug)
24422493
systemPrintf("%s: Value %d > %d, indicating lower priority, stopping device!\r\n",
24432494
networkInterfaceTable[index].name, interfacePriority, networkPriority);
2444-
networkSequenceExit(index, debug);
2495+
networkSequenceExit(index, debug, __FILE__, __LINE__);
24452496
}
24462497

24472498
// This device is still the highest priority, continue the delay and

Firmware/RTK_Everywhere/WiFi.ino

+9-9
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ void menuWiFi()
441441
if (wifiRestartRequested)
442442
{
443443
// Fake the loss of the IP address
444-
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION);
444+
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
445445
wifiReconnectRequest = true;
446446
}
447447

@@ -723,7 +723,7 @@ void wifiStartThrottled(NetIndex_t index, uintptr_t parameter, bool debug)
723723
// Stop the connection attempts
724724
wifiResetThrottleTimeout();
725725
wifiResetTimeout();
726-
networkSequenceStopPolling(NETWORK_WIFI_STATION, debug, true);
726+
networkSequenceExit(NETWORK_WIFI_STATION, debug, __FILE__, __LINE__);
727727
return;
728728
}
729729

@@ -836,7 +836,7 @@ void wifiStationRestart(NetIndex_t index, uintptr_t parameter, bool debug)
836836
// Stop the connection attempts
837837
wifiResetThrottleTimeout();
838838
wifiResetTimeout();
839-
networkSequenceStopPolling(NETWORK_WIFI_STATION, debug, true);
839+
networkSequenceExit(NETWORK_WIFI_STATION, debug, __FILE__, __LINE__);
840840
return;
841841
}
842842

@@ -845,7 +845,7 @@ void wifiStationRestart(NetIndex_t index, uintptr_t parameter, bool debug)
845845
{
846846
// Fake a WiFi failure
847847
networkConsumerReconnect(NETWORK_WIFI_STATION);
848-
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION);
848+
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
849849

850850
// Clear the bits to perform the restart operation
851851
wifi.clearStarted(WIFI_STA_RECONNECT);
@@ -861,7 +861,7 @@ void wifiStationRestart(NetIndex_t index, uintptr_t parameter, bool debug)
861861
// Stop WiFi, used by wifiStopSequence
862862
void wifiStop(NetIndex_t index, uintptr_t parameter, bool debug)
863863
{
864-
networkInterfaceInternetConnectionLost(NETWORK_WIFI_STATION);
864+
networkInterfaceInternetConnectionLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
865865

866866
// Stop WiFi stataion
867867
wifi.enable(wifiEspNowRunning, wifiSoftApRunning, false, __FILE__, __LINE__);
@@ -880,7 +880,7 @@ void wifiStopAll()
880880
wifi.enable(false, false, false, __FILE__, __LINE__);
881881

882882
// Take the network offline
883-
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION);
883+
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
884884

885885
// Display the heap state
886886
reportHeapNow(settings.debugWifiState);
@@ -898,7 +898,7 @@ void wifiWaitNoUsers(NetIndex_t index, uintptr_t parameter, bool debug)
898898
// Stop the connection attempts
899899
wifiResetThrottleTimeout();
900900
wifiResetTimeout();
901-
networkSequenceStopPolling(NETWORK_WIFI_STATION, debug, true);
901+
networkSequenceExit(NETWORK_WIFI_STATION, debug, __FILE__, __LINE__);
902902
return;
903903
}
904904

@@ -1780,7 +1780,7 @@ void RTK_WIFI::stationEventHandler(arduino_event_id_t event, arduino_event_info_
17801780
// Start the reconnection timer
17811781
if (event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED)
17821782
{
1783-
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION);
1783+
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
17841784
wifiReconnectRequest = true;
17851785
}
17861786

@@ -1805,7 +1805,7 @@ void RTK_WIFI::stationEventHandler(arduino_event_id_t event, arduino_event_info_
18051805
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
18061806
if (event == ARDUINO_EVENT_WIFI_STA_LOST_IP)
18071807
{
1808-
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION);
1808+
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
18091809
wifiReconnectRequest = true;
18101810
}
18111811

0 commit comments

Comments
 (0)