@@ -78,6 +78,11 @@ void Application::CheckNewVersion() {
78
78
ESP_LOGE (TAG, " Too many retries, exit version check" );
79
79
return ;
80
80
}
81
+
82
+ char buffer[128 ];
83
+ snprintf (buffer, sizeof (buffer), Lang::Strings::CHECK_NEW_VERSION_FAILED, retry_delay, ota_.GetCheckVersionUrl ().c_str ());
84
+ Alert (Lang::Strings::ERROR, buffer, " sad" , Lang::Sounds::P3_EXCLAMATION);
85
+
81
86
ESP_LOGW (TAG, " Check new version failed, retry in %d seconds (%d/%d)" , retry_delay, retry_count, MAX_RETRY);
82
87
for (int i = 0 ; i < retry_delay; i++) {
83
88
vTaskDelay (pdMS_TO_TICKS (1000 ));
@@ -372,11 +377,16 @@ void Application::Start() {
372
377
373
378
// Initialize the protocol
374
379
display->SetStatus (Lang::Strings::LOADING_PROTOCOL);
375
- #ifdef CONFIG_CONNECTION_TYPE_WEBSOCKET
376
- protocol_ = std::make_unique<WebsocketProtocol>();
377
- #else
378
- protocol_ = std::make_unique<MqttProtocol>();
379
- #endif
380
+
381
+ if (ota_.HasMqttConfig ()) {
382
+ protocol_ = std::make_unique<MqttProtocol>();
383
+ } else if (ota_.HasWebsocketConfig ()) {
384
+ protocol_ = std::make_unique<WebsocketProtocol>();
385
+ } else {
386
+ ESP_LOGW (TAG, " No protocol specified in the OTA config, using MQTT" );
387
+ protocol_ = std::make_unique<MqttProtocol>();
388
+ }
389
+
380
390
protocol_->OnNetworkError ([this ](const std::string& message) {
381
391
SetDeviceState (kDeviceStateIdle );
382
392
Alert (Lang::Strings::ERROR, message.c_str (), " sad" , Lang::Sounds::P3_EXCLAMATION);
@@ -529,7 +539,7 @@ void Application::Start() {
529
539
SetDeviceState (kDeviceStateConnecting );
530
540
wake_word_detect_.EncodeWakeWordData ();
531
541
532
- if (!protocol_->OpenAudioChannel ()) {
542
+ if (!protocol_ || !protocol_ ->OpenAudioChannel ()) {
533
543
wake_word_detect_.StartDetection ();
534
544
return ;
535
545
}
0 commit comments