forked from xiaozhi/xiaozhi-esp32
v1.7.7: 支持 EC801E 模组,增加 xmini-c3-v3, xmini-c3-4g (#930)
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <ml307_mqtt.h>
|
||||
#include <ml307_udp.h>
|
||||
#include <cstring>
|
||||
#include <arpa/inet.h>
|
||||
#include "assets/lang_config.h"
|
||||
@@ -53,7 +51,8 @@ bool MqttProtocol::StartMqttClient(bool report_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mqtt_ = Board::GetInstance().CreateMqtt();
|
||||
auto network = Board::GetInstance().GetNetwork();
|
||||
mqtt_ = network->CreateMqtt(0);
|
||||
mqtt_->SetKeepAlive(keepalive_interval);
|
||||
|
||||
mqtt_->OnDisconnected([this]() {
|
||||
@@ -197,7 +196,9 @@ bool MqttProtocol::OpenAudioChannel() {
|
||||
if (udp_ != nullptr) {
|
||||
delete udp_;
|
||||
}
|
||||
udp_ = Board::GetInstance().CreateUdp();
|
||||
|
||||
auto network = Board::GetInstance().GetNetwork();
|
||||
udp_ = network->CreateUdp(2);
|
||||
udp_->OnMessage([this](const std::string& data) {
|
||||
/*
|
||||
* UDP Encrypted OPUS Packet Format:
|
||||
|
||||
@@ -29,7 +29,7 @@ bool WebsocketProtocol::Start() {
|
||||
}
|
||||
|
||||
bool WebsocketProtocol::SendAudio(const AudioStreamPacket& packet) {
|
||||
if (websocket_ == nullptr) {
|
||||
if (websocket_ == nullptr || !websocket_->IsConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ bool WebsocketProtocol::SendAudio(const AudioStreamPacket& packet) {
|
||||
}
|
||||
|
||||
bool WebsocketProtocol::SendText(const std::string& text) {
|
||||
if (websocket_ == nullptr) {
|
||||
if (websocket_ == nullptr || !websocket_->IsConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,8 +100,9 @@ bool WebsocketProtocol::OpenAudioChannel() {
|
||||
|
||||
error_occurred_ = false;
|
||||
|
||||
websocket_ = Board::GetInstance().CreateWebSocket();
|
||||
|
||||
auto network = Board::GetInstance().GetNetwork();
|
||||
websocket_ = network->CreateWebSocket(1);
|
||||
|
||||
if (!token.empty()) {
|
||||
// If token not has a space, add "Bearer " prefix
|
||||
if (token.find(" ") == std::string::npos) {
|
||||
|
||||
Reference in New Issue
Block a user