perf(websocket): switch WiFi to performance mode before connecting (#1985)
* 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
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user