将项目版本更新至1.5.9,优化内存使用,增加主任务栈大小至8192,优化固件升级流程,重构主循环为MainEventLoop,添加新版本检查功能,更新音频编解码器的DMA配置常量。

This commit is contained in:
Terrence
2025-04-13 11:47:15 +08:00
parent 4ef6ef3552
commit 78d7b40914
20 changed files with 125 additions and 113 deletions

View File

@ -4,7 +4,7 @@
# CMakeLists in this exact order for cmake to work correctly # CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
set(PROJECT_VER "1.5.8") set(PROJECT_VER "1.5.9")
# Add this line to disable the specific warning # Add this line to disable the specific warning
add_compile_options(-Wno-missing-field-initializers) add_compile_options(-Wno-missing-field-initializers)

View File

@ -48,6 +48,7 @@ Application::Application() {
.skip_unhandled_events = true .skip_unhandled_events = true
}; };
esp_timer_create(&clock_timer_args, &clock_timer_handle_); esp_timer_create(&clock_timer_args, &clock_timer_handle_);
esp_timer_start_periodic(clock_timer_handle_, 1000000);
} }
Application::~Application() { Application::~Application() {
@ -81,58 +82,49 @@ void Application::CheckNewVersion() {
if (ota_.HasNewVersion()) { if (ota_.HasNewVersion()) {
Alert(Lang::Strings::OTA_UPGRADE, Lang::Strings::UPGRADING, "happy", Lang::Sounds::P3_UPGRADE); Alert(Lang::Strings::OTA_UPGRADE, Lang::Strings::UPGRADING, "happy", Lang::Sounds::P3_UPGRADE);
// Wait for the chat state to be idle
do {
vTaskDelay(pdMS_TO_TICKS(3000));
} while (GetDeviceState() != kDeviceStateIdle);
// Use main task to do the upgrade, not cancelable vTaskDelay(pdMS_TO_TICKS(3000));
Schedule([this, display]() {
SetDeviceState(kDeviceStateUpgrading);
display->SetIcon(FONT_AWESOME_DOWNLOAD);
std::string message = std::string(Lang::Strings::NEW_VERSION) + ota_.GetFirmwareVersion();
display->SetChatMessage("system", message.c_str());
auto& board = Board::GetInstance(); SetDeviceState(kDeviceStateUpgrading);
board.SetPowerSaveMode(false);
display->SetIcon(FONT_AWESOME_DOWNLOAD);
std::string message = std::string(Lang::Strings::NEW_VERSION) + ota_.GetFirmwareVersion();
display->SetChatMessage("system", message.c_str());
auto& board = Board::GetInstance();
board.SetPowerSaveMode(false);
#if CONFIG_USE_WAKE_WORD_DETECT #if CONFIG_USE_WAKE_WORD_DETECT
wake_word_detect_.StopDetection(); wake_word_detect_.StopDetection();
#endif #endif
// 预先关闭音频输出,避免升级过程有音频操作 // 预先关闭音频输出,避免升级过程有音频操作
auto codec = board.GetAudioCodec(); auto codec = board.GetAudioCodec();
codec->EnableInput(false); codec->EnableInput(false);
codec->EnableOutput(false); codec->EnableOutput(false);
{ {
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
audio_decode_queue_.clear(); audio_decode_queue_.clear();
} }
background_task_->WaitForCompletion(); background_task_->WaitForCompletion();
delete background_task_; delete background_task_;
background_task_ = nullptr; background_task_ = nullptr;
vTaskDelay(pdMS_TO_TICKS(1000)); vTaskDelay(pdMS_TO_TICKS(1000));
ota_.StartUpgrade([display](int progress, size_t speed) { ota_.StartUpgrade([display](int progress, size_t speed) {
char buffer[64]; char buffer[64];
snprintf(buffer, sizeof(buffer), "%d%% %zuKB/s", progress, speed / 1024); snprintf(buffer, sizeof(buffer), "%d%% %zuKB/s", progress, speed / 1024);
display->SetChatMessage("system", buffer); display->SetChatMessage("system", buffer);
});
// If upgrade success, the device will reboot and never reach here
display->SetStatus(Lang::Strings::UPGRADE_FAILED);
ESP_LOGI(TAG, "Firmware upgrade failed...");
vTaskDelay(pdMS_TO_TICKS(3000));
Reboot();
}); });
// If upgrade success, the device will reboot and never reach here
display->SetStatus(Lang::Strings::UPGRADE_FAILED);
ESP_LOGI(TAG, "Firmware upgrade failed...");
vTaskDelay(pdMS_TO_TICKS(3000));
Reboot();
return; return;
} }
// No new version, mark the current version as valid // No new version, mark the current version as valid
ota_.MarkCurrentVersionValid(); ota_.MarkCurrentVersionValid();
std::string message = std::string(Lang::Strings::VERSION) + ota_.GetCurrentVersion();
display->ShowNotification(message.c_str());
if (ota_.HasActivationCode()) { if (ota_.HasActivationCode()) {
// Activation code is valid // Activation code is valid
SetDeviceState(kDeviceStateActivating); SetDeviceState(kDeviceStateActivating);
@ -148,11 +140,8 @@ void Application::CheckNewVersion() {
continue; continue;
} }
SetDeviceState(kDeviceStateIdle); xEventGroupSetBits(event_group_, CHECK_NEW_VERSION_DONE_EVENT);
display->SetChatMessage("system", ""); // Exit the loop if done checking new version
ResetDecoder();
PlaySound(Lang::Sounds::P3_SUCCESS);
// Exit the loop if upgrade or idle
break; break;
} }
} }
@ -180,8 +169,6 @@ void Application::ShowActivationCode() {
// This sentence uses 9KB of SRAM, so we need to wait for it to finish // This sentence uses 9KB of SRAM, so we need to wait for it to finish
Alert(Lang::Strings::ACTIVATION, message.c_str(), "happy", Lang::Sounds::P3_ACTIVATION); Alert(Lang::Strings::ACTIVATION, message.c_str(), "happy", Lang::Sounds::P3_ACTIVATION);
vTaskDelay(pdMS_TO_TICKS(1000));
background_task_->WaitForCompletion();
for (const auto& digit : code) { for (const auto& digit : code) {
auto it = std::find_if(digit_sounds.begin(), digit_sounds.end(), auto it = std::find_if(digit_sounds.begin(), digit_sounds.end(),
@ -214,6 +201,15 @@ void Application::DismissAlert() {
} }
void Application::PlaySound(const std::string_view& sound) { void Application::PlaySound(const std::string_view& sound) {
// Wait for the previous sound to finish
{
std::unique_lock<std::mutex> lock(mutex_);
audio_decode_cv_.wait(lock, [this]() {
return audio_decode_queue_.empty();
});
}
background_task_->WaitForCompletion();
// The assets are encoded at 16000Hz, 60ms frame duration // The assets are encoded at 16000Hz, 60ms frame duration
SetDecodeSampleRate(16000, 60); SetDecodeSampleRate(16000, 60);
const char* data = sound.data(); const char* data = sound.data();
@ -295,6 +291,16 @@ void Application::StartListening() {
} }
void Application::StopListening() { void Application::StopListening() {
const std::array<int, 3> valid_states = {
kDeviceStateListening,
kDeviceStateSpeaking,
kDeviceStateIdle,
};
// If not valid, do nothing
if (std::find(valid_states.begin(), valid_states.end(), device_state_) == valid_states.end()) {
return;
}
Schedule([this]() { Schedule([this]() {
if (device_state_ == kDeviceStateListening) { if (device_state_ == kDeviceStateListening) {
protocol_->SendStopListening(); protocol_->SendStopListening();
@ -337,16 +343,13 @@ void Application::Start() {
vTaskDelete(NULL); vTaskDelete(NULL);
}, "audio_loop", 4096 * 2, this, 8, &audio_loop_task_handle_, realtime_chat_enabled_ ? 1 : 0); }, "audio_loop", 4096 * 2, this, 8, &audio_loop_task_handle_, realtime_chat_enabled_ ? 1 : 0);
/* Start the main loop */
xTaskCreatePinnedToCore([](void* arg) {
Application* app = (Application*)arg;
app->MainLoop();
vTaskDelete(NULL);
}, "main_loop", 4096 * 2, this, 4, &main_loop_task_handle_, 0);
/* Wait for the network to be ready */ /* Wait for the network to be ready */
board.StartNetwork(); board.StartNetwork();
// Check for new firmware version or get the MQTT broker address
display->SetStatus(Lang::Strings::CHECKING_NEW_VERSION);
CheckNewVersion();
// Initialize the protocol // Initialize the protocol
display->SetStatus(Lang::Strings::LOADING_PROTOCOL); display->SetStatus(Lang::Strings::LOADING_PROTOCOL);
#ifdef CONFIG_CONNECTION_TYPE_WEBSOCKET #ifdef CONFIG_CONNECTION_TYPE_WEBSOCKET
@ -444,13 +447,6 @@ void Application::Start() {
}); });
protocol_->Start(); protocol_->Start();
// Check for new firmware version or get the MQTT broker address
xTaskCreate([](void* arg) {
Application* app = (Application*)arg;
app->CheckNewVersion();
vTaskDelete(NULL);
}, "check_new_version", 4096 * 2, this, 2, nullptr);
#if CONFIG_USE_AUDIO_PROCESSOR #if CONFIG_USE_AUDIO_PROCESSOR
audio_processor_.Initialize(codec, realtime_chat_enabled_); audio_processor_.Initialize(codec, realtime_chat_enabled_);
audio_processor_.OnOutput([this](std::vector<int16_t>&& data) { audio_processor_.OnOutput([this](std::vector<int16_t>&& data) {
@ -509,15 +505,18 @@ void Application::Start() {
wake_word_detect_.StartDetection(); wake_word_detect_.StartDetection();
#endif #endif
// Wait for the new version check to finish
xEventGroupWaitBits(event_group_, CHECK_NEW_VERSION_DONE_EVENT, pdTRUE, pdFALSE, portMAX_DELAY);
SetDeviceState(kDeviceStateIdle); SetDeviceState(kDeviceStateIdle);
esp_timer_start_periodic(clock_timer_handle_, 1000000); std::string message = std::string(Lang::Strings::VERSION) + ota_.GetCurrentVersion();
display->ShowNotification(message.c_str());
#if 0 display->SetChatMessage("system", "");
while (true) { // Play the success sound to indicate the device is ready
SystemInfo::PrintRealTimeStats(pdMS_TO_TICKS(1000)); ResetDecoder();
vTaskDelay(pdMS_TO_TICKS(10000)); PlaySound(Lang::Sounds::P3_SUCCESS);
}
#endif // Enter the main event loop
MainEventLoop();
} }
void Application::OnClockTimer() { void Application::OnClockTimer() {
@ -553,10 +552,10 @@ void Application::Schedule(std::function<void()> callback) {
xEventGroupSetBits(event_group_, SCHEDULE_EVENT); xEventGroupSetBits(event_group_, SCHEDULE_EVENT);
} }
// The Main Loop controls the chat state and websocket connection // The Main Event Loop controls the chat state and websocket connection
// If other tasks need to access the websocket or chat state, // If other tasks need to access the websocket or chat state,
// they should use Schedule to call this function // they should use Schedule to call this function
void Application::MainLoop() { void Application::MainEventLoop() {
while (true) { while (true) {
auto bits = xEventGroupWaitBits(event_group_, SCHEDULE_EVENT, pdTRUE, pdFALSE, portMAX_DELAY); auto bits = xEventGroupWaitBits(event_group_, SCHEDULE_EVENT, pdTRUE, pdFALSE, portMAX_DELAY);
@ -601,12 +600,14 @@ void Application::OnAudioOutput() {
if (device_state_ == kDeviceStateListening) { if (device_state_ == kDeviceStateListening) {
audio_decode_queue_.clear(); audio_decode_queue_.clear();
audio_decode_cv_.notify_all();
return; return;
} }
auto opus = std::move(audio_decode_queue_.front()); auto opus = std::move(audio_decode_queue_.front());
audio_decode_queue_.pop_front(); audio_decode_queue_.pop_front();
lock.unlock(); lock.unlock();
audio_decode_cv_.notify_all();
background_task_->Schedule([this, codec, opus = std::move(opus)]() mutable { background_task_->Schedule([this, codec, opus = std::move(opus)]() mutable {
if (aborted_) { if (aborted_) {
@ -630,10 +631,9 @@ void Application::OnAudioOutput() {
} }
void Application::OnAudioInput() { void Application::OnAudioInput() {
std::vector<int16_t> data;
#if CONFIG_USE_WAKE_WORD_DETECT #if CONFIG_USE_WAKE_WORD_DETECT
if (wake_word_detect_.IsDetectionRunning()) { if (wake_word_detect_.IsDetectionRunning()) {
std::vector<int16_t> data;
ReadAudio(data, 16000, wake_word_detect_.GetFeedSize()); ReadAudio(data, 16000, wake_word_detect_.GetFeedSize());
wake_word_detect_.Feed(data); wake_word_detect_.Feed(data);
return; return;
@ -641,12 +641,14 @@ void Application::OnAudioInput() {
#endif #endif
#if CONFIG_USE_AUDIO_PROCESSOR #if CONFIG_USE_AUDIO_PROCESSOR
if (audio_processor_.IsRunning()) { if (audio_processor_.IsRunning()) {
std::vector<int16_t> data;
ReadAudio(data, 16000, audio_processor_.GetFeedSize()); ReadAudio(data, 16000, audio_processor_.GetFeedSize());
audio_processor_.Feed(data); audio_processor_.Feed(data);
return; return;
} }
#else #else
if (device_state_ == kDeviceStateListening) { if (device_state_ == kDeviceStateListening) {
std::vector<int16_t> data;
ReadAudio(data, 16000, 30 * 16000 / 1000); ReadAudio(data, 16000, 30 * 16000 / 1000);
background_task_->Schedule([this, data = std::move(data)]() mutable { background_task_->Schedule([this, data = std::move(data)]() mutable {
opus_encoder_->Encode(std::move(data), [this](std::vector<uint8_t>&& opus) { opus_encoder_->Encode(std::move(data), [this](std::vector<uint8_t>&& opus) {
@ -792,6 +794,7 @@ void Application::ResetDecoder() {
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
opus_decoder_->ResetState(); opus_decoder_->ResetState();
audio_decode_queue_.clear(); audio_decode_queue_.clear();
audio_decode_cv_.notify_all();
last_output_time_ = std::chrono::steady_clock::now(); last_output_time_ = std::chrono::steady_clock::now();
auto codec = Board::GetInstance().GetAudioCodec(); auto codec = Board::GetInstance().GetAudioCodec();

View File

@ -9,6 +9,8 @@
#include <string> #include <string>
#include <mutex> #include <mutex>
#include <list> #include <list>
#include <vector>
#include <condition_variable>
#include <opus_encoder.h> #include <opus_encoder.h>
#include <opus_decoder.h> #include <opus_decoder.h>
@ -28,6 +30,7 @@
#define SCHEDULE_EVENT (1 << 0) #define SCHEDULE_EVENT (1 << 0)
#define AUDIO_INPUT_READY_EVENT (1 << 1) #define AUDIO_INPUT_READY_EVENT (1 << 1)
#define AUDIO_OUTPUT_READY_EVENT (1 << 2) #define AUDIO_OUTPUT_READY_EVENT (1 << 2)
#define CHECK_NEW_VERSION_DONE_EVENT (1 << 3)
enum DeviceState { enum DeviceState {
kDeviceStateUnknown, kDeviceStateUnknown,
@ -97,7 +100,6 @@ private:
bool aborted_ = false; bool aborted_ = false;
bool voice_detected_ = false; bool voice_detected_ = false;
int clock_ticks_ = 0; int clock_ticks_ = 0;
TaskHandle_t main_loop_task_handle_ = nullptr;
TaskHandle_t check_new_version_task_handle_ = nullptr; TaskHandle_t check_new_version_task_handle_ = nullptr;
// Audio encode / decode // Audio encode / decode
@ -105,6 +107,7 @@ private:
BackgroundTask* background_task_ = nullptr; BackgroundTask* background_task_ = nullptr;
std::chrono::steady_clock::time_point last_output_time_; std::chrono::steady_clock::time_point last_output_time_;
std::list<std::vector<uint8_t>> audio_decode_queue_; std::list<std::vector<uint8_t>> audio_decode_queue_;
std::condition_variable audio_decode_cv_;
std::unique_ptr<OpusEncoderWrapper> opus_encoder_; std::unique_ptr<OpusEncoderWrapper> opus_encoder_;
std::unique_ptr<OpusDecoderWrapper> opus_decoder_; std::unique_ptr<OpusDecoderWrapper> opus_decoder_;
@ -113,7 +116,7 @@ private:
OpusResampler reference_resampler_; OpusResampler reference_resampler_;
OpusResampler output_resampler_; OpusResampler output_resampler_;
void MainLoop(); void MainEventLoop();
void OnAudioInput(); void OnAudioInput();
void OnAudioOutput(); void OnAudioOutput();
void ReadAudio(std::vector<int16_t>& data, int sample_rate, int samples); void ReadAudio(std::vector<int16_t>& data, int sample_rate, int samples);

View File

@ -7,7 +7,8 @@
"INFO": "Information", "INFO": "Information",
"ERROR": "Error", "ERROR": "Error",
"VERSION": "Ver ", "VERSION": "Ver ",
"LOADING_PROTOCOL": "Loading Protocol...", "LOADING_PROTOCOL": "Logging in...",
"CHECKING_NEW_VERSION": "Checking for new version...",
"INITIALIZING": "Initializing...", "INITIALIZING": "Initializing...",
"PIN_ERROR": "Please insert SIM card", "PIN_ERROR": "Please insert SIM card",
"REG_ERROR": "Unable to access network, please check SIM card status", "REG_ERROR": "Unable to access network, please check SIM card status",

View File

@ -7,12 +7,13 @@
"INFO": "情報", "INFO": "情報",
"ERROR": "エラー", "ERROR": "エラー",
"VERSION": "バージョン ", "VERSION": "バージョン ",
"LOADING_PROTOCOL": "プロトコルを読み込み中...", "LOADING_PROTOCOL": "サーバーにログイン中...",
"INITIALIZING": "初期化中...", "INITIALIZING": "初期化中...",
"PIN_ERROR": "SIMカードを挿入してください", "PIN_ERROR": "SIMカードを挿入してください",
"REG_ERROR": "ネットワークに接続できません。ネットワーク状態を確認してください", "REG_ERROR": "ネットワークに接続できません。ネットワーク状態を確認してください",
"DETECTING_MODULE": "モジュールを検出中...", "DETECTING_MODULE": "モジュールを検出中...",
"REGISTERING_NETWORK": "ネットワーク接続待機中...", "REGISTERING_NETWORK": "ネットワーク接続待機中...",
"CHECKING_NEW_VERSION": "新しいバージョンを確認中...",
"STANDBY": "待機中", "STANDBY": "待機中",
"CONNECT_TO": "接続先 ", "CONNECT_TO": "接続先 ",

View File

@ -7,12 +7,13 @@
"INFO":"信息", "INFO":"信息",
"ERROR":"错误", "ERROR":"错误",
"VERSION": "版本 ", "VERSION": "版本 ",
"LOADING_PROTOCOL":"加载协议...", "LOADING_PROTOCOL":"登录服务器...",
"INITIALIZING":"正在初始化...", "INITIALIZING":"正在初始化...",
"PIN_ERROR":"请插入 SIM 卡", "PIN_ERROR":"请插入 SIM 卡",
"REG_ERROR":"无法接入网络,请检查流量卡状态", "REG_ERROR":"无法接入网络,请检查流量卡状态",
"DETECTING_MODULE":"检测模组...", "DETECTING_MODULE":"检测模组...",
"REGISTERING_NETWORK":"等待网络...", "REGISTERING_NETWORK":"等待网络...",
"CHECKING_NEW_VERSION":"检查新版本...",
"STANDBY":"待命", "STANDBY":"待命",
"CONNECT_TO":"连接 ", "CONNECT_TO":"连接 ",

View File

@ -7,12 +7,13 @@
"INFO": "資訊", "INFO": "資訊",
"ERROR": "錯誤", "ERROR": "錯誤",
"VERSION": "版本 ", "VERSION": "版本 ",
"LOADING_PROTOCOL": "加載協議...", "LOADING_PROTOCOL": "登入伺服器...",
"INITIALIZING": "正在初始化...", "INITIALIZING": "正在初始化...",
"PIN_ERROR": "請插入 SIM 卡", "PIN_ERROR": "請插入 SIM 卡",
"REG_ERROR": "無法接入網絡,請檢查網路狀態", "REG_ERROR": "無法接入網絡,請檢查網路狀態",
"DETECTING_MODULE": "檢測模組...", "DETECTING_MODULE": "檢測模組...",
"REGISTERING_NETWORK": "等待網絡...", "REGISTERING_NETWORK": "等待網絡...",
"CHECKING_NEW_VERSION": "檢查新版本...",
"STANDBY": "待命", "STANDBY": "待命",
"CONNECT_TO": "連接 ", "CONNECT_TO": "連接 ",

View File

@ -11,6 +11,9 @@
#include "board.h" #include "board.h"
#define AUDIO_CODEC_DMA_DESC_NUM 6
#define AUDIO_CODEC_DMA_FRAME_NUM 240
class AudioCodec { class AudioCodec {
public: public:
AudioCodec(); AudioCodec();

View File

@ -96,8 +96,8 @@ void BoxAudioCodec::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk, gpio_
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,

View File

@ -80,8 +80,8 @@ void Es8311AudioCodec::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk, gp
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,

View File

@ -85,8 +85,8 @@ void Es8388AudioCodec::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk, gp
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,

View File

@ -23,8 +23,8 @@ NoAudioCodecDuplex::NoAudioCodecDuplex(int input_sample_rate, int output_sample_
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,
@ -82,8 +82,8 @@ ATK_NoAudioCodecDuplex::ATK_NoAudioCodecDuplex(int input_sample_rate, int output
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,
@ -141,8 +141,8 @@ NoAudioCodecSimplex::NoAudioCodecSimplex(int input_sample_rate, int output_sampl
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = (i2s_port_t)0, .id = (i2s_port_t)0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,
@ -210,8 +210,8 @@ NoAudioCodecSimplex::NoAudioCodecSimplex(int input_sample_rate, int output_sampl
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = (i2s_port_t)0, .id = (i2s_port_t)0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,
@ -278,8 +278,8 @@ NoAudioCodecSimplexPdm::NoAudioCodecSimplexPdm(int input_sample_rate, int output
// Create a new channel for speaker // Create a new channel for speaker
i2s_chan_config_t tx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG((i2s_port_t)1, I2S_ROLE_MASTER); i2s_chan_config_t tx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG((i2s_port_t)1, I2S_ROLE_MASTER);
tx_chan_cfg.dma_desc_num = 6; tx_chan_cfg.dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM;
tx_chan_cfg.dma_frame_num = 240; tx_chan_cfg.dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM;
tx_chan_cfg.auto_clear_after_cb = true; tx_chan_cfg.auto_clear_after_cb = true;
tx_chan_cfg.auto_clear_before_cb = false; tx_chan_cfg.auto_clear_before_cb = false;
tx_chan_cfg.intr_priority = 0; tx_chan_cfg.intr_priority = 0;

View File

@ -74,8 +74,8 @@ void K10AudioCodec::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk, gpio_
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,

View File

@ -97,8 +97,8 @@ void BoxAudioCodecLite::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk, g
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,

View File

@ -99,8 +99,8 @@ void CoreS3AudioCodec::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk, gp
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,

View File

@ -98,8 +98,8 @@ void SensecapAudioCodec::CreateDuplexChannels(gpio_num_t mclk, gpio_num_t bclk,
i2s_chan_config_t chan_cfg = { i2s_chan_config_t chan_cfg = {
.id = I2S_NUM_0, .id = I2S_NUM_0,
.role = I2S_ROLE_MASTER, .role = I2S_ROLE_MASTER,
.dma_desc_num = 6, .dma_desc_num = AUDIO_CODEC_DMA_DESC_NUM,
.dma_frame_num = 240, .dma_frame_num = AUDIO_CODEC_DMA_FRAME_NUM,
.auto_clear_after_cb = true, .auto_clear_after_cb = true,
.auto_clear_before_cb = false, .auto_clear_before_cb = false,
.intr_priority = 0, .intr_priority = 0,

View File

@ -8,8 +8,8 @@ dependencies:
espressif/esp_io_expander_tca9554: "==2.0.0" espressif/esp_io_expander_tca9554: "==2.0.0"
espressif/esp_lcd_panel_io_additions: "^1.0.1" espressif/esp_lcd_panel_io_additions: "^1.0.1"
78/esp_lcd_nv3023: "~1.0.0" 78/esp_lcd_nv3023: "~1.0.0"
78/esp-wifi-connect: "~2.3.1" 78/esp-wifi-connect: "~2.3.2"
78/esp-opus-encoder: "~2.3.0" 78/esp-opus-encoder: "~2.3.1"
78/esp-ml307: "~1.8.1" 78/esp-ml307: "~1.8.1"
78/xiaozhi-fonts: "~1.3.2" 78/xiaozhi-fonts: "~1.3.2"
espressif/led_strip: "^2.4.1" espressif/led_strip: "^2.4.1"

View File

@ -26,5 +26,4 @@ extern "C" void app_main(void)
// Launch the application // Launch the application
Application::GetInstance().Start(); Application::GetInstance().Start();
// The main thread will exit and release the stack memory
} }

View File

@ -58,15 +58,15 @@ bool Ota::CheckVersion() {
http->SetHeader("Accept-Language", Lang::CODE); http->SetHeader("Accept-Language", Lang::CODE);
http->SetHeader("Content-Type", "application/json"); http->SetHeader("Content-Type", "application/json");
std::string post_data = board.GetJson(); std::string data = board.GetJson();
std::string method = post_data.length() > 0 ? "POST" : "GET"; std::string method = data.length() > 0 ? "POST" : "GET";
if (!http->Open(method, check_version_url_, post_data)) { if (!http->Open(method, check_version_url_, data)) {
ESP_LOGE(TAG, "Failed to open HTTP connection"); ESP_LOGE(TAG, "Failed to open HTTP connection");
delete http; delete http;
return false; return false;
} }
auto response = http->GetBody(); data = http->GetBody();
http->Close(); http->Close();
delete http; delete http;
@ -74,7 +74,7 @@ bool Ota::CheckVersion() {
// Parse the JSON response and check if the version is newer // Parse the JSON response and check if the version is newer
// If it is, set has_new_version_ to true and store the new version and URL // If it is, set has_new_version_ to true and store the new version and URL
cJSON *root = cJSON_Parse(response.c_str()); cJSON *root = cJSON_Parse(data.c_str());
if (root == NULL) { if (root == NULL) {
ESP_LOGE(TAG, "Failed to parse JSON response"); ESP_LOGE(TAG, "Failed to parse JSON response");
return false; return false;

View File

@ -17,7 +17,7 @@ CONFIG_ESP_TASK_WDT_TIMEOUT_S=10
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=n CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=n
CONFIG_ESP_WIFI_IRAM_OPT=n CONFIG_ESP_WIFI_IRAM_OPT=n