Skip to content

Commit

Permalink
OTA: make sure WiFi is enabled in HW failure case
Browse files Browse the repository at this point in the history
  • Loading branch information
PBrunot committed Jul 28, 2024
1 parent f100206 commit bd9af72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/OTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace fabomatic
void configModeCallback(WiFiManager *myWiFiManager)
{
ESP_LOGI(TAG, "Entering portal config mode");
ESP_LOGD(TAG, "%s", WiFi.softAPIP().toString().c_str());
ESP_LOGD(TAG, "%s", myWiFiManager->getConfigPortalSSID().c_str());
ESP_LOGD(TAG, "IP: %s", WiFi.softAPIP().toString().c_str());
ESP_LOGD(TAG, "SSID: %s", myWiFiManager->getConfigPortalSSID().c_str());
Board::logic.changeStatus(Status::PortalStarting);
}

Expand Down
10 changes: 9 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,14 @@ void setup()
fabomatic::startMQTTBrocker();
#endif

if (!WiFi.isConnected())
{
if (!logic.getServer().connectWiFi())
{
ESP_LOGI(TAG, "WiFi connection failed.");
}
}

fabomatic::setupOTA();

if (!hw_init)
Expand All @@ -480,7 +488,7 @@ void setup()
logic.blinkLed(64, 0, 0);
logic.changeStatus(fabomatic::BoardLogic::Status::ErrorHardware);
fabomatic::Tasks::delay(1s);
ESP_LOGE(TAG, "Hardware failed, waiting for OTA");
ESP_LOGE(TAG, "Hardware failed, waiting for OTA on IP %s", WiFi.localIP().toString().c_str());
}
}

Expand Down

0 comments on commit bd9af72

Please sign in to comment.