5
5
#include " audio_codec.h"
6
6
#include " mqtt_protocol.h"
7
7
#include " websocket_protocol.h"
8
- #include " font_awesome_symbols.h"
9
8
#include " assets/lang_config.h"
10
9
#include " mcp_server.h"
11
10
14
13
#include < cJSON.h>
15
14
#include < driver/gpio.h>
16
15
#include < arpa/inet.h>
16
+ #include < font_awesome.h>
17
17
18
18
#define TAG " Application"
19
19
@@ -87,7 +87,7 @@ void Application::CheckNewVersion(Ota& ota) {
87
87
88
88
char buffer[256 ];
89
89
snprintf (buffer, sizeof (buffer), Lang::Strings::CHECK_NEW_VERSION_FAILED, retry_delay, ota.GetCheckVersionUrl ().c_str ());
90
- Alert (Lang::Strings::ERROR, buffer, " sad " , Lang::Sounds::OGG_EXCLAMATION);
90
+ Alert (Lang::Strings::ERROR, buffer, " cloud_slash " , Lang::Sounds::OGG_EXCLAMATION);
91
91
92
92
ESP_LOGW (TAG, " Check new version failed, retry in %d seconds (%d/%d)" , retry_delay, retry_count, MAX_RETRY);
93
93
for (int i = 0 ; i < retry_delay; i++) {
@@ -103,13 +103,12 @@ void Application::CheckNewVersion(Ota& ota) {
103
103
retry_delay = 10 ; // 重置重试延迟时间
104
104
105
105
if (ota.HasNewVersion ()) {
106
- Alert (Lang::Strings::OTA_UPGRADE, Lang::Strings::UPGRADING, " happy " , Lang::Sounds::OGG_UPGRADE);
106
+ Alert (Lang::Strings::OTA_UPGRADE, Lang::Strings::UPGRADING, " download " , Lang::Sounds::OGG_UPGRADE);
107
107
108
108
vTaskDelay (pdMS_TO_TICKS (3000 ));
109
109
110
110
SetDeviceState (kDeviceStateUpgrading );
111
111
112
- display->SetIcon (FONT_AWESOME_DOWNLOAD);
113
112
std::string message = std::string (Lang::Strings::NEW_VERSION) + ota.GetFirmwareVersion ();
114
113
display->SetChatMessage (" system" , message.c_str ());
115
114
@@ -130,7 +129,7 @@ void Application::CheckNewVersion(Ota& ota) {
130
129
ESP_LOGE (TAG, " Firmware upgrade failed, restarting audio service and continuing operation..." );
131
130
audio_service_.Start (); // Restart audio service
132
131
board.SetPowerSaveMode (true ); // Restore power save mode
133
- Alert (Lang::Strings::ERROR, Lang::Strings::UPGRADE_FAILED, " sad " , Lang::Sounds::OGG_EXCLAMATION);
132
+ Alert (Lang::Strings::ERROR, Lang::Strings::UPGRADE_FAILED, " circle_xmark " , Lang::Sounds::OGG_EXCLAMATION);
134
133
vTaskDelay (pdMS_TO_TICKS (3000 ));
135
134
// Continue to normal operation (don't break, just fall through)
136
135
} else {
@@ -195,7 +194,7 @@ void Application::ShowActivationCode(const std::string& code, const std::string&
195
194
}};
196
195
197
196
// This sentence uses 9KB of SRAM, so we need to wait for it to finish
198
- Alert (Lang::Strings::ACTIVATION, message.c_str (), " happy " , Lang::Sounds::OGG_ACTIVATION);
197
+ Alert (Lang::Strings::ACTIVATION, message.c_str (), " link " , Lang::Sounds::OGG_ACTIVATION);
199
198
200
199
for (const auto & digit : code) {
201
200
auto it = std::find_if (digit_sounds.begin (), digit_sounds.end (),
@@ -207,7 +206,7 @@ void Application::ShowActivationCode(const std::string& code, const std::string&
207
206
}
208
207
209
208
void Application::Alert (const char * status, const char * message, const char * emotion, const std::string_view& sound) {
210
- ESP_LOGW (TAG, " Alert %s: %s [%s] " , status, message, emotion );
209
+ ESP_LOGW (TAG, " Alert [%s] %s: %s " , emotion, status, message );
211
210
auto display = Board::GetInstance ().GetDisplay ();
212
211
display->SetStatus (status);
213
212
display->SetEmotion (emotion);
@@ -378,6 +377,10 @@ void Application::Start() {
378
377
protocol_ = std::make_unique<MqttProtocol>();
379
378
}
380
379
380
+ protocol_->OnConnected ([this ]() {
381
+ DismissAlert ();
382
+ });
383
+
381
384
protocol_->OnNetworkError ([this ](const std::string& message) {
382
385
last_error_message_ = message;
383
386
xEventGroupSetBits (event_group_, MAIN_EVENT_ERROR);
@@ -546,7 +549,7 @@ void Application::MainEventLoop() {
546
549
MAIN_EVENT_ERROR, pdTRUE, pdFALSE, portMAX_DELAY);
547
550
if (bits & MAIN_EVENT_ERROR) {
548
551
SetDeviceState (kDeviceStateIdle );
549
- Alert (Lang::Strings::ERROR, last_error_message_.c_str (), " sad " , Lang::Sounds::OGG_EXCLAMATION);
552
+ Alert (Lang::Strings::ERROR, last_error_message_.c_str (), " circle_xmark " , Lang::Sounds::OGG_EXCLAMATION);
550
553
}
551
554
552
555
if (bits & MAIN_EVENT_SEND_AUDIO) {
0 commit comments