From cc132876e78f8a8a6313e1065e2ef030465660b1 Mon Sep 17 00:00:00 2001 From: Rene Zeldenthuis Date: Tue, 20 Sep 2022 13:59:47 +0200 Subject: [PATCH] MDNS already done by iotConf. Start OTA when connected --- src/main.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c733649..ade5581 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -243,11 +243,6 @@ void setup() web_server.onNotFound([]() { iotWebConf.handleNotFound(); }); - // Set DNS to thing name - MDNS.begin(iotWebConf.getThingName()); - // Add service to mDNS - http - MDNS.addService("http", "tcp", 80); - ArduinoOTA .onStart([]() { log_w("Starting OTA update: %s", ArduinoOTA.getCommand() == U_FLASH ? "sketch" : "filesystem"); }) @@ -266,9 +261,11 @@ void setup() case OTA_END_ERROR: log_e("OTA: End Failed"); break; default: log_e("OTA error: %u", error); } }); - // Start (OTA) Over The Air programming ArduinoOTA.setPassword(OTA_PASSWORD); - ArduinoOTA.begin(); + + // Start (OTA) Over The Air programming when connected + iotWebConf.setWifiConnectionCallback([]() + { ArduinoOTA.begin(); }); } void loop()