From 38a1f8c7d11c9f505be6e15e6f3b391c0d7c02ae Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Wed, 15 Apr 2020 00:23:11 +0900 Subject: [PATCH] Changed evaluation timing of AutoConnectOTA enabled --- src/AutoConnect.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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) {