From 778e4f433f27404b649bbc2b48b22b9c92684eb6 Mon Sep 17 00:00:00 2001 From: Terrence Date: Tue, 4 Mar 2025 00:28:58 +0800 Subject: [PATCH] set User-Agent --- main/application.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/application.cc b/main/application.cc index 01b9cc56..7682a0f2 100644 --- a/main/application.cc +++ b/main/application.cc @@ -15,6 +15,7 @@ #include #include #include +#include #define TAG "Application" @@ -295,8 +296,6 @@ void Application::StartListening() { Schedule([this]() { AbortSpeaking(kAbortReasonNone); protocol_->SendStartListening(kListeningModeManualStop); - // FIXME: Wait for the speaker to empty the buffer - vTaskDelay(pdMS_TO_TICKS(120)); SetDeviceState(kDeviceStateListening); }); } @@ -462,6 +461,8 @@ void Application::Start() { ota_.SetHeader("Device-Id", SystemInfo::GetMacAddress().c_str()); ota_.SetHeader("Client-Id", board.GetUuid()); ota_.SetHeader("Accept-Language", Lang::CODE); + auto app_desc = esp_app_get_description(); + ota_.SetHeader("User-Agent", std::string(BOARD_NAME "/") + app_desc->version); xTaskCreate([](void* arg) { Application* app = (Application*)arg; @@ -713,6 +714,7 @@ void Application::SetDeviceState(DeviceState state) { return; } + auto previous_state = device_state_; device_state_ = state; ESP_LOGI(TAG, "STATE: %s", STATE_STRINGS[device_state_]); // The state is changed, wait for all background tasks to finish @@ -746,6 +748,10 @@ void Application::SetDeviceState(DeviceState state) { audio_processor_.Start(); #endif UpdateIotStates(); + if (previous_state == kDeviceStateSpeaking) { + // FIXME: Wait for the speaker to empty the buffer + vTaskDelay(pdMS_TO_TICKS(120)); + } break; case kDeviceStateSpeaking: display->SetStatus(Lang::Strings::SPEAKING);