forked from xiaozhi/xiaozhi-esp32
set User-Agent
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include <cJSON.h>
|
#include <cJSON.h>
|
||||||
#include <driver/gpio.h>
|
#include <driver/gpio.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <esp_app_desc.h>
|
||||||
|
|
||||||
#define TAG "Application"
|
#define TAG "Application"
|
||||||
|
|
||||||
@@ -295,8 +296,6 @@ void Application::StartListening() {
|
|||||||
Schedule([this]() {
|
Schedule([this]() {
|
||||||
AbortSpeaking(kAbortReasonNone);
|
AbortSpeaking(kAbortReasonNone);
|
||||||
protocol_->SendStartListening(kListeningModeManualStop);
|
protocol_->SendStartListening(kListeningModeManualStop);
|
||||||
// FIXME: Wait for the speaker to empty the buffer
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(120));
|
|
||||||
SetDeviceState(kDeviceStateListening);
|
SetDeviceState(kDeviceStateListening);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -462,6 +461,8 @@ void Application::Start() {
|
|||||||
ota_.SetHeader("Device-Id", SystemInfo::GetMacAddress().c_str());
|
ota_.SetHeader("Device-Id", SystemInfo::GetMacAddress().c_str());
|
||||||
ota_.SetHeader("Client-Id", board.GetUuid());
|
ota_.SetHeader("Client-Id", board.GetUuid());
|
||||||
ota_.SetHeader("Accept-Language", Lang::CODE);
|
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) {
|
xTaskCreate([](void* arg) {
|
||||||
Application* app = (Application*)arg;
|
Application* app = (Application*)arg;
|
||||||
@@ -713,6 +714,7 @@ void Application::SetDeviceState(DeviceState state) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto previous_state = device_state_;
|
||||||
device_state_ = state;
|
device_state_ = state;
|
||||||
ESP_LOGI(TAG, "STATE: %s", STATE_STRINGS[device_state_]);
|
ESP_LOGI(TAG, "STATE: %s", STATE_STRINGS[device_state_]);
|
||||||
// The state is changed, wait for all background tasks to finish
|
// The state is changed, wait for all background tasks to finish
|
||||||
@@ -746,6 +748,10 @@ void Application::SetDeviceState(DeviceState state) {
|
|||||||
audio_processor_.Start();
|
audio_processor_.Start();
|
||||||
#endif
|
#endif
|
||||||
UpdateIotStates();
|
UpdateIotStates();
|
||||||
|
if (previous_state == kDeviceStateSpeaking) {
|
||||||
|
// FIXME: Wait for the speaker to empty the buffer
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(120));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case kDeviceStateSpeaking:
|
case kDeviceStateSpeaking:
|
||||||
display->SetStatus(Lang::Strings::SPEAKING);
|
display->SetStatus(Lang::Strings::SPEAKING);
|
||||||
|
|||||||
Reference in New Issue
Block a user