Update to esp-ml307@3.1.1

This commit is contained in:
Terrence
2025-07-21 05:46:05 +08:00
parent a35a344f42
commit d1c047d060
10 changed files with 19 additions and 38 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.8.0") set(PROJECT_VER "1.8.1")
# 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

@@ -210,7 +210,7 @@ std::string Esp32Camera::Explain(const std::string& question) {
}); });
auto network = Board::GetInstance().GetNetwork(); auto network = Board::GetInstance().GetNetwork();
auto http = std::unique_ptr<Http>(network->CreateHttp(3)); auto http = network->CreateHttp(3);
// 构造multipart/form-data请求体 // 构造multipart/form-data请求体
std::string boundary = "----ESP32_CAMERA_BOUNDARY"; std::string boundary = "----ESP32_CAMERA_BOUNDARY";

View File

@@ -279,7 +279,7 @@ std::string SscmaCamera::Explain(const std::string& question) {
} }
auto network = Board::GetInstance().GetNetwork(); auto network = Board::GetInstance().GetNetwork();
auto http = std::unique_ptr<Http>(network->CreateHttp(3)); auto http = network->CreateHttp(3);
// 构造multipart/form-data请求体 // 构造multipart/form-data请求体
std::string boundary = "----ESP32_CAMERA_BOUNDARY"; std::string boundary = "----ESP32_CAMERA_BOUNDARY";

View File

@@ -15,7 +15,7 @@ dependencies:
78/esp_lcd_nv3023: ~1.0.0 78/esp_lcd_nv3023: ~1.0.0
78/esp-wifi-connect: ~2.4.3 78/esp-wifi-connect: ~2.4.3
78/esp-opus-encoder: ~2.4.0 78/esp-opus-encoder: ~2.4.0
78/esp-ml307: ~3.0.2 78/esp-ml307: ~3.1.1
78/xiaozhi-fonts: ~1.3.2 78/xiaozhi-fonts: ~1.3.2
espressif/led_strip: ^2.5.5 espressif/led_strip: ^2.5.5
espressif/esp_codec_dev: ~1.3.2 espressif/esp_codec_dev: ~1.3.2

View File

@@ -49,7 +49,7 @@ std::string Ota::GetCheckVersionUrl() {
return url; return url;
} }
Http* Ota::SetupHttp() { std::unique_ptr<Http> Ota::SetupHttp() {
auto& board = Board::GetInstance(); auto& board = Board::GetInstance();
auto app_desc = esp_app_get_description(); auto app_desc = esp_app_get_description();
@@ -85,7 +85,7 @@ bool Ota::CheckVersion() {
return false; return false;
} }
auto http = std::unique_ptr<Http>(SetupHttp()); auto http = SetupHttp();
std::string data = board.GetJson(); std::string data = board.GetJson();
std::string method = data.length() > 0 ? "POST" : "GET"; std::string method = data.length() > 0 ? "POST" : "GET";
@@ -274,7 +274,7 @@ bool Ota::Upgrade(const std::string& firmware_url) {
std::string image_header; std::string image_header;
auto network = Board::GetInstance().GetNetwork(); auto network = Board::GetInstance().GetNetwork();
auto http = std::unique_ptr<Http>(network->CreateHttp(0)); auto http = network->CreateHttp(0);
if (!http->Open("GET", firmware_url)) { if (!http->Open("GET", firmware_url)) {
ESP_LOGE(TAG, "Failed to open HTTP connection"); ESP_LOGE(TAG, "Failed to open HTTP connection");
return false; return false;
@@ -452,7 +452,7 @@ esp_err_t Ota::Activate() {
url += "activate"; url += "activate";
} }
auto http = std::unique_ptr<Http>(SetupHttp()); auto http = SetupHttp();
std::string data = GetActivationPayload(); std::string data = GetActivationPayload();
http->SetContent(std::move(data)); http->SetContent(std::move(data));

View File

@@ -51,7 +51,7 @@ private:
std::vector<int> ParseVersion(const std::string& version); std::vector<int> ParseVersion(const std::string& version);
bool IsNewVersionAvailable(const std::string& currentVersion, const std::string& newVersion); bool IsNewVersionAvailable(const std::string& currentVersion, const std::string& newVersion);
std::string GetActivationPayload(); std::string GetActivationPayload();
Http* SetupHttp(); std::unique_ptr<Http> SetupHttp();
}; };
#endif // _OTA_H #endif // _OTA_H

View File

@@ -16,12 +16,6 @@ MqttProtocol::MqttProtocol() {
MqttProtocol::~MqttProtocol() { MqttProtocol::~MqttProtocol() {
ESP_LOGI(TAG, "MqttProtocol deinit"); ESP_LOGI(TAG, "MqttProtocol deinit");
if (udp_ != nullptr) {
delete udp_;
}
if (mqtt_ != nullptr) {
delete mqtt_;
}
vEventGroupDelete(event_group_handle_); vEventGroupDelete(event_group_handle_);
} }
@@ -32,7 +26,7 @@ bool MqttProtocol::Start() {
bool MqttProtocol::StartMqttClient(bool report_error) { bool MqttProtocol::StartMqttClient(bool report_error) {
if (mqtt_ != nullptr) { if (mqtt_ != nullptr) {
ESP_LOGW(TAG, "Mqtt client already started"); ESP_LOGW(TAG, "Mqtt client already started");
delete mqtt_; mqtt_.reset();
} }
Settings settings("mqtt", false); Settings settings("mqtt", false);
@@ -150,10 +144,7 @@ bool MqttProtocol::SendAudio(std::unique_ptr<AudioStreamPacket> packet) {
void MqttProtocol::CloseAudioChannel() { void MqttProtocol::CloseAudioChannel() {
{ {
std::lock_guard<std::mutex> lock(channel_mutex_); std::lock_guard<std::mutex> lock(channel_mutex_);
if (udp_ != nullptr) { udp_.reset();
delete udp_;
udp_ = nullptr;
}
} }
std::string message = "{"; std::string message = "{";
@@ -193,10 +184,6 @@ bool MqttProtocol::OpenAudioChannel() {
} }
std::lock_guard<std::mutex> lock(channel_mutex_); std::lock_guard<std::mutex> lock(channel_mutex_);
if (udp_ != nullptr) {
delete udp_;
}
auto network = Board::GetInstance().GetNetwork(); auto network = Board::GetInstance().GetNetwork();
udp_ = network->CreateUdp(2); udp_ = network->CreateUdp(2);
udp_->OnMessage([this](const std::string& data) { udp_->OnMessage([this](const std::string& data) {

View File

@@ -37,8 +37,8 @@ private:
std::string publish_topic_; std::string publish_topic_;
std::mutex channel_mutex_; std::mutex channel_mutex_;
Mqtt* mqtt_ = nullptr; std::unique_ptr<Mqtt> mqtt_;
Udp* udp_ = nullptr; std::unique_ptr<Udp> udp_;
mbedtls_aes_context aes_ctx_; mbedtls_aes_context aes_ctx_;
std::string aes_nonce_; std::string aes_nonce_;
std::string udp_server_; std::string udp_server_;

View File

@@ -17,9 +17,6 @@ WebsocketProtocol::WebsocketProtocol() {
} }
WebsocketProtocol::~WebsocketProtocol() { WebsocketProtocol::~WebsocketProtocol() {
if (websocket_ != nullptr) {
delete websocket_;
}
vEventGroupDelete(event_group_handle_); vEventGroupDelete(event_group_handle_);
} }
@@ -79,17 +76,10 @@ bool WebsocketProtocol::IsAudioChannelOpened() const {
} }
void WebsocketProtocol::CloseAudioChannel() { void WebsocketProtocol::CloseAudioChannel() {
if (websocket_ != nullptr) { websocket_.reset();
delete websocket_;
websocket_ = nullptr;
}
} }
bool WebsocketProtocol::OpenAudioChannel() { bool WebsocketProtocol::OpenAudioChannel() {
if (websocket_ != nullptr) {
delete websocket_;
}
Settings settings("websocket", false); Settings settings("websocket", false);
std::string url = settings.GetString("url"); std::string url = settings.GetString("url");
std::string token = settings.GetString("token"); std::string token = settings.GetString("token");
@@ -102,6 +92,10 @@ bool WebsocketProtocol::OpenAudioChannel() {
auto network = Board::GetInstance().GetNetwork(); auto network = Board::GetInstance().GetNetwork();
websocket_ = network->CreateWebSocket(1); websocket_ = network->CreateWebSocket(1);
if (websocket_ == nullptr) {
ESP_LOGE(TAG, "Failed to create websocket");
return false;
}
if (!token.empty()) { if (!token.empty()) {
// If token not has a space, add "Bearer " prefix // If token not has a space, add "Bearer " prefix

View File

@@ -23,7 +23,7 @@ public:
private: private:
EventGroupHandle_t event_group_handle_; EventGroupHandle_t event_group_handle_;
WebSocket* websocket_ = nullptr; std::unique_ptr<WebSocket> websocket_;
int version_ = 1; int version_ = 1;
void ParseServerHello(const cJSON* root); void ParseServerHello(const cJSON* root);