From 417f52d7597b85f3dfc6f5283bdc66df34fbd5fe Mon Sep 17 00:00:00 2001 From: liuzhe910422 <80535750+liuzhe910422@users.noreply.github.com> Date: Thu, 14 May 2026 14:36:14 +0800 Subject: [PATCH] perf(websocket): switch WiFi to performance mode before connecting (#1985) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf(websocket): switch WiFi to performance mode before connecting Optimize WebSocket connection speed by switching WiFi to performance mode before establishing the connection, instead of after. This reduces network latency significantly: - TCP connection: 1093ms → 88ms (92% faster) - WebSocket handshake: 1035ms → 80ms (92% faster) - Total network layer: 2128ms → 173ms (92% faster) The issue was caused by WiFi power save mode (MAX_MODEM) which adds significant latency to packet transmission. * Adjust formatting --- main/application.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main/application.cc b/main/application.cc index a30bb7a..d54ac6b 100644 --- a/main/application.cc +++ b/main/application.cc @@ -716,6 +716,10 @@ void Application::ContinueOpenAudioChannel(ListeningMode mode) { return; } + // Switch to performance mode before connecting to reduce latency + auto& board = Board::GetInstance(); + board.SetPowerSaveLevel(PowerSaveLevel::PERFORMANCE); + if (!protocol_->IsAudioChannelOpened()) { if (!protocol_->OpenAudioChannel()) { return; @@ -825,6 +829,10 @@ void Application::ContinueWakeWordInvoke(const std::string& wake_word) { return; } + // Switch to performance mode before connecting to reduce latency + auto& board = Board::GetInstance(); + board.SetPowerSaveLevel(PowerSaveLevel::PERFORMANCE); + if (!protocol_->IsAudioChannelOpened()) { if (!protocol_->OpenAudioChannel()) { audio_service_.EnableWakeWordDetection(true);