From 57414094666becd6dfa3d8c9cf0dbfd3602d70ea Mon Sep 17 00:00:00 2001 From: Johnathon Slightham Date: Wed, 7 Jan 2026 11:12:03 -0500 Subject: [PATCH] Fix wireless restarts itself after intentionally disabled --- components/rpc/include/wireless/WifiManager.h | 2 +- components/rpc/wireless/UDPServer.cpp | 1 - components/rpc/wireless/WifiManager.cpp | 8 ++++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/components/rpc/include/wireless/WifiManager.h b/components/rpc/include/wireless/WifiManager.h index 718796e..5cebc28 100644 --- a/components/rpc/include/wireless/WifiManager.h +++ b/components/rpc/include/wireless/WifiManager.h @@ -28,7 +28,7 @@ public: [[noreturn]] void manage(); - enum class wifi_state { connect, connecting, connected, disconnect, disconnected, broadcast, broadcasting }; + enum class wifi_state { connect, connecting, connected, disconnect, disconnected, broadcast, broadcasting, shutdown, disabled }; private: void update_state(wifi_state state); diff --git a/components/rpc/wireless/UDPServer.cpp b/components/rpc/wireless/UDPServer.cpp index a178772..06ab69b 100644 --- a/components/rpc/wireless/UDPServer.cpp +++ b/components/rpc/wireless/UDPServer.cpp @@ -135,7 +135,6 @@ void UDPServer::shutdown() { auto buffer = std::make_unique>(); buffer->resize(MAX_RX_BUFFER_SIZE + 4); - ESP_LOGI(TAG, "Before rx"); if (int len = recvfrom(that->m_rx_server_sock, buffer->data(), MAX_RX_BUFFER_SIZE, 0, nullptr, nullptr); len < 0) { diff --git a/components/rpc/wireless/WifiManager.cpp b/components/rpc/wireless/WifiManager.cpp index 588745b..c8870ba 100644 --- a/components/rpc/wireless/WifiManager.cpp +++ b/components/rpc/wireless/WifiManager.cpp @@ -21,7 +21,7 @@ int WifiManager::connect() { } int WifiManager::disconnect() { - this->update_state(wifi_state::disconnect); + this->update_state(wifi_state::shutdown); vTaskResume(this->m_task); return 0; } @@ -55,7 +55,7 @@ int WifiManager::disconnect() { handle_broadcasting(); // scans for known networks break; case wifi_state::disconnect: - ESP_LOGI(TAG, "Shutting down wifi"); + ESP_LOGI(TAG, "Shutting down wifi (will restart)"); handle_disconnect(); update_state(wifi_state::disconnected); break; @@ -63,6 +63,10 @@ int WifiManager::disconnect() { ESP_LOGI(TAG, "Disconnected from wifi, starting back up"); update_state(wifi_state::connect); break; + case wifi_state::shutdown: + ESP_LOGI(TAG, "Shutting down wifi (will not automatically restart)"); + handle_disconnect(); + update_state(wifi_state::disabled); default: vTaskSuspend(nullptr); break;