@@ -78,6 +78,11 @@ void Application::CheckNewVersion() {
7878 ESP_LOGE (TAG, " Too many retries, exit version check" );
7979 return ;
8080 }
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+
8186 ESP_LOGW (TAG, " Check new version failed, retry in %d seconds (%d/%d)" , retry_delay, retry_count, MAX_RETRY);
8287 for (int i = 0 ; i < retry_delay; i++) {
8388 vTaskDelay (pdMS_TO_TICKS (1000 ));
@@ -372,11 +377,16 @@ void Application::Start() {
372377
373378 // Initialize the protocol
374379 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+
380390 protocol_->OnNetworkError ([this ](const std::string& message) {
381391 SetDeviceState (kDeviceStateIdle );
382392 Alert (Lang::Strings::ERROR, message.c_str (), " sad" , Lang::Sounds::P3_EXCLAMATION);
@@ -529,7 +539,7 @@ void Application::Start() {
529539 SetDeviceState (kDeviceStateConnecting );
530540 wake_word_detect_.EncodeWakeWordData ();
531541
532- if (!protocol_->OpenAudioChannel ()) {
542+ if (!protocol_ || !protocol_ ->OpenAudioChannel ()) {
533543 wake_word_detect_.StartDetection ();
534544 return ;
535545 }
0 commit comments