forked from xiaozhi/xiaozhi-esp32
Update to esp-ml307@3.1.1
This commit is contained in:
@@ -210,7 +210,7 @@ std::string Esp32Camera::Explain(const std::string& question) {
|
||||
});
|
||||
|
||||
auto network = Board::GetInstance().GetNetwork();
|
||||
auto http = std::unique_ptr<Http>(network->CreateHttp(3));
|
||||
auto http = network->CreateHttp(3);
|
||||
// 构造multipart/form-data请求体
|
||||
std::string boundary = "----ESP32_CAMERA_BOUNDARY";
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ std::string SscmaCamera::Explain(const std::string& question) {
|
||||
}
|
||||
|
||||
auto network = Board::GetInstance().GetNetwork();
|
||||
auto http = std::unique_ptr<Http>(network->CreateHttp(3));
|
||||
auto http = network->CreateHttp(3);
|
||||
// 构造multipart/form-data请求体
|
||||
std::string boundary = "----ESP32_CAMERA_BOUNDARY";
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ dependencies:
|
||||
78/esp_lcd_nv3023: ~1.0.0
|
||||
78/esp-wifi-connect: ~2.4.3
|
||||
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
|
||||
espressif/led_strip: ^2.5.5
|
||||
espressif/esp_codec_dev: ~1.3.2
|
||||
|
||||
@@ -49,7 +49,7 @@ std::string Ota::GetCheckVersionUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
Http* Ota::SetupHttp() {
|
||||
std::unique_ptr<Http> Ota::SetupHttp() {
|
||||
auto& board = Board::GetInstance();
|
||||
auto app_desc = esp_app_get_description();
|
||||
|
||||
@@ -85,7 +85,7 @@ bool Ota::CheckVersion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto http = std::unique_ptr<Http>(SetupHttp());
|
||||
auto http = SetupHttp();
|
||||
|
||||
std::string data = board.GetJson();
|
||||
std::string method = data.length() > 0 ? "POST" : "GET";
|
||||
@@ -274,7 +274,7 @@ bool Ota::Upgrade(const std::string& firmware_url) {
|
||||
std::string image_header;
|
||||
|
||||
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)) {
|
||||
ESP_LOGE(TAG, "Failed to open HTTP connection");
|
||||
return false;
|
||||
@@ -452,7 +452,7 @@ esp_err_t Ota::Activate() {
|
||||
url += "activate";
|
||||
}
|
||||
|
||||
auto http = std::unique_ptr<Http>(SetupHttp());
|
||||
auto http = SetupHttp();
|
||||
|
||||
std::string data = GetActivationPayload();
|
||||
http->SetContent(std::move(data));
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
std::vector<int> ParseVersion(const std::string& version);
|
||||
bool IsNewVersionAvailable(const std::string& currentVersion, const std::string& newVersion);
|
||||
std::string GetActivationPayload();
|
||||
Http* SetupHttp();
|
||||
std::unique_ptr<Http> SetupHttp();
|
||||
};
|
||||
|
||||
#endif // _OTA_H
|
||||
|
||||
@@ -16,12 +16,6 @@ MqttProtocol::MqttProtocol() {
|
||||
|
||||
MqttProtocol::~MqttProtocol() {
|
||||
ESP_LOGI(TAG, "MqttProtocol deinit");
|
||||
if (udp_ != nullptr) {
|
||||
delete udp_;
|
||||
}
|
||||
if (mqtt_ != nullptr) {
|
||||
delete mqtt_;
|
||||
}
|
||||
vEventGroupDelete(event_group_handle_);
|
||||
}
|
||||
|
||||
@@ -32,7 +26,7 @@ bool MqttProtocol::Start() {
|
||||
bool MqttProtocol::StartMqttClient(bool report_error) {
|
||||
if (mqtt_ != nullptr) {
|
||||
ESP_LOGW(TAG, "Mqtt client already started");
|
||||
delete mqtt_;
|
||||
mqtt_.reset();
|
||||
}
|
||||
|
||||
Settings settings("mqtt", false);
|
||||
@@ -150,10 +144,7 @@ bool MqttProtocol::SendAudio(std::unique_ptr<AudioStreamPacket> packet) {
|
||||
void MqttProtocol::CloseAudioChannel() {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(channel_mutex_);
|
||||
if (udp_ != nullptr) {
|
||||
delete udp_;
|
||||
udp_ = nullptr;
|
||||
}
|
||||
udp_.reset();
|
||||
}
|
||||
|
||||
std::string message = "{";
|
||||
@@ -193,10 +184,6 @@ bool MqttProtocol::OpenAudioChannel() {
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(channel_mutex_);
|
||||
if (udp_ != nullptr) {
|
||||
delete udp_;
|
||||
}
|
||||
|
||||
auto network = Board::GetInstance().GetNetwork();
|
||||
udp_ = network->CreateUdp(2);
|
||||
udp_->OnMessage([this](const std::string& data) {
|
||||
|
||||
@@ -37,8 +37,8 @@ private:
|
||||
std::string publish_topic_;
|
||||
|
||||
std::mutex channel_mutex_;
|
||||
Mqtt* mqtt_ = nullptr;
|
||||
Udp* udp_ = nullptr;
|
||||
std::unique_ptr<Mqtt> mqtt_;
|
||||
std::unique_ptr<Udp> udp_;
|
||||
mbedtls_aes_context aes_ctx_;
|
||||
std::string aes_nonce_;
|
||||
std::string udp_server_;
|
||||
|
||||
@@ -17,9 +17,6 @@ WebsocketProtocol::WebsocketProtocol() {
|
||||
}
|
||||
|
||||
WebsocketProtocol::~WebsocketProtocol() {
|
||||
if (websocket_ != nullptr) {
|
||||
delete websocket_;
|
||||
}
|
||||
vEventGroupDelete(event_group_handle_);
|
||||
}
|
||||
|
||||
@@ -79,17 +76,10 @@ bool WebsocketProtocol::IsAudioChannelOpened() const {
|
||||
}
|
||||
|
||||
void WebsocketProtocol::CloseAudioChannel() {
|
||||
if (websocket_ != nullptr) {
|
||||
delete websocket_;
|
||||
websocket_ = nullptr;
|
||||
}
|
||||
websocket_.reset();
|
||||
}
|
||||
|
||||
bool WebsocketProtocol::OpenAudioChannel() {
|
||||
if (websocket_ != nullptr) {
|
||||
delete websocket_;
|
||||
}
|
||||
|
||||
Settings settings("websocket", false);
|
||||
std::string url = settings.GetString("url");
|
||||
std::string token = settings.GetString("token");
|
||||
@@ -102,6 +92,10 @@ bool WebsocketProtocol::OpenAudioChannel() {
|
||||
|
||||
auto network = Board::GetInstance().GetNetwork();
|
||||
websocket_ = network->CreateWebSocket(1);
|
||||
if (websocket_ == nullptr) {
|
||||
ESP_LOGE(TAG, "Failed to create websocket");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!token.empty()) {
|
||||
// If token not has a space, add "Bearer " prefix
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
|
||||
private:
|
||||
EventGroupHandle_t event_group_handle_;
|
||||
WebSocket* websocket_ = nullptr;
|
||||
std::unique_ptr<WebSocket> websocket_;
|
||||
int version_ = 1;
|
||||
|
||||
void ParseServerHello(const cJSON* root);
|
||||
|
||||
Reference in New Issue
Block a user