Skip to content

Commit a4d39ca

Browse files
committed
fix: stop TCP client and release sockets before WiFi restart to prevent resource leaks
1 parent 40d0854 commit a4d39ca

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ void handleCaptive() {
227227
// ---------------------------------------------------------------------------
228228
void startWiFi() {
229229
Serial.println("Initializing WiFi...");
230+
udpDiscovery.stop();
231+
udp11881.stop();
232+
udp.stop();
233+
tcpServer.stop();
234+
server.stop();
230235

231236
if (config.wifi_mode == "STA") {
232237
WiFi.mode(WIFI_STA);
@@ -489,6 +494,7 @@ void loop() {
489494
if (!config.usb_bridge) Serial.println("TCP Session Started.");
490495
}
491496
if (activeMode == MODE_WIFI_TCP && !tcpClient.connected()) {
497+
tcpClient.stop();
492498
activeMode = MODE_NONE;
493499
if (!config.usb_bridge) Serial.println("TCP Session Ended.");
494500
}

0 commit comments

Comments
 (0)