Skip to content

Commit ac6e0d3

Browse files
committed
Add ethernetUpdate and ethernetRestartRequested
Restart Ethernet when disconnected, to free any TCP resources
1 parent d72e1ff commit ac6e0d3

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
// Ethernet
1010
//----------------------------------------
1111

12-
bool ethernetLinkUp() {return false;}
13-
void menuEthernet() {systemPrintln("**Ethernet not compiled**");}
12+
bool ethernetLinkUp() {return false;}
13+
void menuEthernet() {systemPrintln("**Ethernet not compiled**");}
14+
void ethernetUpdate() {}
1415

1516
bool ntpLogIncreasing = false;
1617

Firmware/RTK_Everywhere/Ethernet.ino

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ void ethernetEvent(arduino_event_id_t event, arduino_event_info_t info)
188188
case ARDUINO_EVENT_ETH_DISCONNECTED:
189189
if (settings.enablePrintEthernetDiag && (!inMainMenu))
190190
systemPrintln("ETH Disconnected");
191+
192+
ethernetRestartRequested = true; // Perform ETH.end() to disconnect TCP resources
193+
191194
break;
192195

193196
case ARDUINO_EVENT_ETH_STOP:
@@ -236,6 +239,20 @@ const char *ethernetGetEventName(arduino_event_id_t event)
236239
}
237240
}
238241

242+
//----------------------------------------
243+
// Update Ethernet. Restart if requested
244+
//----------------------------------------
245+
void ethernetUpdate()
246+
{
247+
if (ethernetRestartRequested)
248+
{
249+
if (settings.enablePrintEthernetDiag && (!inMainMenu))
250+
systemPrintln("Restarting Ethernet");
251+
ethernetRestart();
252+
ethernetRestartRequested = false;
253+
}
254+
}
255+
239256
//----------------------------------------
240257
// Restart the Ethernet controller
241258
//----------------------------------------

Firmware/RTK_Everywhere/Network.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,6 +2453,9 @@ void networkUpdate()
24532453
// Update the WiFi state
24542454
wifiStationUpdate();
24552455

2456+
// Update Ethernet
2457+
ethernetUpdate();
2458+
24562459
// Update the network services
24572460
// Start or stop mDNS
24582461
if (networkMdnsRequests != networkMdnsRunning)

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ IPAddress ethernetSubnetMask;
737737
// };
738738
volatile struct timeval ethernetNtpTv; // This will hold the time the Ethernet NTP packet arrived
739739
bool ntpLogIncreasing;
740+
bool ethernetRestartRequested = false; // Perform ETH.end() to disconnect TCP resources
740741
#endif // COMPILE_ETHERNET
741742

742743
unsigned long lastEthernetCheck; // Prevents cable checking from continually happening

0 commit comments

Comments
 (0)