diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index 85d170b..dff239c 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -95,13 +95,6 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long _ticker->start(AUTOCONNECT_FLICKER_PERIODDC, (uint8_t)AUTOCONNECT_FLICKER_WIDTHDC); } - // Attach AutoConnectOTA if OTA is available. - if (_apConfig.ota == AC_OTA_BUILTIN) { - _ota.reset(new AutoConnectOTA()); - _ota->attach(*this); - _ota->setTicker(_apConfig.tickerPort, _apConfig.tickerOn); - } - // Advance configuration for STA mode. Restore previous configuration of STA. station_config_t current; if (_getConfigSTA(¤t)) { @@ -594,6 +587,15 @@ void AutoConnect::handleRequest(void) { if (_update) _update->handleUpdate(); + // Attach AutoConnectOTA if OTA is available. + if (_apConfig.ota == AC_OTA_BUILTIN) { + if (!_ota) { + _ota.reset(new AutoConnectOTA()); + _ota->attach(*this); + _ota->setTicker(_apConfig.tickerPort, _apConfig.tickerOn); + } + } + // Post-process for AutoConnectOTA if (_ota) { if (_ota->status() == AutoConnectOTA::OTA_RIP) {