Fix wireless restarts itself after intentionally disabled

This commit is contained in:
2026-01-07 11:12:03 -05:00
parent 86d773ea2d
commit f1b7c6fced
3 changed files with 7 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ public:
[[noreturn]] void manage(); [[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: private:
void update_state(wifi_state state); void update_state(wifi_state state);

View File

@@ -135,7 +135,6 @@ void UDPServer::shutdown() {
auto buffer = std::make_unique<std::vector<uint8_t>>(); auto buffer = std::make_unique<std::vector<uint8_t>>();
buffer->resize(MAX_RX_BUFFER_SIZE + 4); buffer->resize(MAX_RX_BUFFER_SIZE + 4);
ESP_LOGI(TAG, "Before rx");
if (int len = recvfrom(that->m_rx_server_sock, buffer->data(), if (int len = recvfrom(that->m_rx_server_sock, buffer->data(),
MAX_RX_BUFFER_SIZE, 0, nullptr, nullptr); MAX_RX_BUFFER_SIZE, 0, nullptr, nullptr);
len < 0) { len < 0) {

View File

@@ -21,7 +21,7 @@ int WifiManager::connect() {
} }
int WifiManager::disconnect() { int WifiManager::disconnect() {
this->update_state(wifi_state::disconnect); this->update_state(wifi_state::shutdown);
vTaskResume(this->m_task); vTaskResume(this->m_task);
return 0; return 0;
} }
@@ -55,7 +55,7 @@ int WifiManager::disconnect() {
handle_broadcasting(); // scans for known networks handle_broadcasting(); // scans for known networks
break; break;
case wifi_state::disconnect: case wifi_state::disconnect:
ESP_LOGI(TAG, "Shutting down wifi"); ESP_LOGI(TAG, "Shutting down wifi (will restart)");
handle_disconnect(); handle_disconnect();
update_state(wifi_state::disconnected); update_state(wifi_state::disconnected);
break; break;
@@ -63,6 +63,10 @@ int WifiManager::disconnect() {
ESP_LOGI(TAG, "Disconnected from wifi, starting back up"); ESP_LOGI(TAG, "Disconnected from wifi, starting back up");
update_state(wifi_state::connect); update_state(wifi_state::connect);
break; break;
case wifi_state::shutdown:
ESP_LOGI(TAG, "Shutting down wifi (will not automatically restart)");
handle_disconnect();
update_state(wifi_state::disabled);
default: default:
vTaskSuspend(nullptr); vTaskSuspend(nullptr);
break; break;