4 Commits
main ... ws

Author SHA1 Message Date
4953244c7c fix: voice interrupt 2026-05-22 10:20:00 +08:00
5223333418 fix: voice interrupt 2026-05-22 10:10:16 +08:00
61ad9dafd9 fix: text display 2026-05-21 17:05:09 +08:00
928d40826f feat: ws connect 2026-05-18 15:56:50 +08:00
5 changed files with 1107 additions and 4 deletions

View File

@ -6,6 +6,34 @@ config OTA_URL
help
The application will access this URL to check for new firmwares and server address.
config USE_DIRECT_WEBSOCKET
bool "Use direct WebSocket without OTA"
default n
help
Skip the OTA server check and use the WebSocket settings below directly.
config WEBSOCKET_URL
string "Default WebSocket URL"
depends on USE_DIRECT_WEBSOCKET
default "ws://10.6.80.130:8080"
help
The WebSocket server URL used when direct WebSocket mode is enabled.
config WEBSOCKET_TOKEN
string "Default WebSocket token"
depends on USE_DIRECT_WEBSOCKET
default ""
help
Optional Authorization token for the direct WebSocket server.
config WEBSOCKET_PROTOCOL_VERSION
int "Default WebSocket protocol version"
depends on USE_DIRECT_WEBSOCKET
range 1 3
default 1
help
Protocol-Version header and hello version used by the WebSocket protocol.
choice
prompt "Flash Assets"
default FLASH_DEFAULT_ASSETS if !USE_EMOTE_MESSAGE_STYLE

View File

@ -302,11 +302,15 @@ void Application::HandleActivationDoneEvent() {
SystemInfo::PrintHeapStats();
SetDeviceState(kDeviceStateIdle);
has_server_time_ = ota_->HasServerTime();
if (ota_ != nullptr) {
has_server_time_ = ota_->HasServerTime();
}
auto display = Board::GetInstance().GetDisplay();
std::string message = std::string(Lang::Strings::VERSION) + ota_->GetCurrentVersion();
display->ShowNotification(message.c_str());
if (ota_ != nullptr) {
std::string message = std::string(Lang::Strings::VERSION) + ota_->GetCurrentVersion();
display->ShowNotification(message.c_str());
}
display->SetChatMessage("system", "");
// Release OTA object after activation is complete
@ -321,6 +325,10 @@ void Application::HandleActivationDoneEvent() {
}
void Application::ActivationTask() {
#if CONFIG_USE_DIRECT_WEBSOCKET
CheckAssetsVersion();
InitializeProtocol();
#else
// Create OTA object for activation process
ota_ = std::make_unique<Ota>();
@ -332,6 +340,7 @@ void Application::ActivationTask() {
// Initialize the protocol
InitializeProtocol();
#endif
// Signal completion to main loop
xEventGroupSetBits(event_group_, MAIN_EVENT_ACTIVATION_DONE);
@ -477,6 +486,9 @@ void Application::InitializeProtocol() {
display->SetStatus(Lang::Strings::LOADING_PROTOCOL);
#if CONFIG_USE_DIRECT_WEBSOCKET
protocol_ = std::make_unique<WebsocketProtocol>();
#else
if (ota_->HasMqttConfig()) {
protocol_ = std::make_unique<MqttProtocol>();
} else if (ota_->HasWebsocketConfig()) {
@ -485,6 +497,7 @@ void Application::InitializeProtocol() {
ESP_LOGW(TAG, "No protocol specified in the OTA config, using MQTT");
protocol_ = std::make_unique<MqttProtocol>();
}
#endif
protocol_->OnConnected([this]() {
DismissAlert();
@ -1128,4 +1141,3 @@ void Application::ResetProtocol() {
protocol_.reset();
});
}

View File

@ -598,6 +598,10 @@ CONFIG_PARTITION_TABLE_MD5=y
# Xiaozhi Assistant
#
CONFIG_OTA_URL="https://api.tenclass.net/xiaozhi/ota/"
CONFIG_USE_DIRECT_WEBSOCKET=y
CONFIG_WEBSOCKET_URL="ws://10.6.80.130:8080"
CONFIG_WEBSOCKET_TOKEN=""
CONFIG_WEBSOCKET_PROTOCOL_VERSION=1
# CONFIG_FLASH_NONE_ASSETS is not set
CONFIG_FLASH_DEFAULT_ASSETS=y
# CONFIG_FLASH_CUSTOM_ASSETS is not set

1048
main/bridge_server.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -85,10 +85,21 @@ bool WebsocketProtocol::OpenAudioChannel() {
std::string url = settings.GetString("url");
std::string token = settings.GetString("token");
int version = settings.GetInt("version");
#if CONFIG_USE_DIRECT_WEBSOCKET
url = CONFIG_WEBSOCKET_URL;
token = CONFIG_WEBSOCKET_TOKEN;
version = CONFIG_WEBSOCKET_PROTOCOL_VERSION;
#endif
if (version != 0) {
version_ = version;
}
if (url.empty()) {
ESP_LOGE(TAG, "Websocket URL is not set");
SetError(Lang::Strings::SERVER_NOT_CONNECTED);
return false;
}
error_occurred_ = false;
auto network = Board::GetInstance().GetNetwork();