From 371606942af339013902ba9b99ea7a752de56282 Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Fri, 10 Apr 2020 23:56:43 +0900 Subject: [PATCH] Adds menu config of AutoConnectOTA --- src/AutoConnect.cpp | 9 ++++++--- src/AutoConnectOTA.h | 9 +++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index 3644037..2928cde 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -96,7 +96,7 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long } // Attach AutoConnectOTA if OTA is available. - if (_apConfig.ota) { + if (_apConfig.ota != AC_OTA_NONE) { _ota.reset(new AutoConnectOTA()); _ota->attach(*this); _ota->setTicker(_apConfig.tickerPort, _apConfig.tickerOn); @@ -594,13 +594,16 @@ void AutoConnect::handleRequest(void) { if (_update) _update->handleUpdate(); - // Indicate the reboot at the next handleClient turn - // with on completion of the update via OTA. + // Post-process for AutoConnectOTA if (_ota) { if (_ota->status() == AutoConnectOTA::OTA_RIP) { + // Indicate the reboot at the next handleClient turn + // with on completion of the update via OTA. _webServer->client().setNoDelay(true); _rfReset = true; } + // Reflect the menu display specifier from AutoConnectConfig to AutoConnectOTA page + _ota->menu(_apConfig.menuItems & AC_MENUITEM_UPDATE); } } diff --git a/src/AutoConnectOTA.h b/src/AutoConnectOTA.h index bca1cd1..2e0d2ef 100644 --- a/src/AutoConnectOTA.h +++ b/src/AutoConnectOTA.h @@ -36,9 +36,10 @@ class AutoConnectOTA : public AutoConnectUploadHandler { AutoConnectOTA() : _status(OTA_IDLE), _tickerPort(-1), _tickerOn(LOW) {} ~AutoConnectOTA(); void attach(AutoConnect& portal); - String error(void) const { return _err; } - AC_OTAStatus_t status(void) const { return _status; } - void setTicker(uint8_t pin, uint8_t on) { _tickerPort = pin, _tickerOn = on; } + String error(void) const { return _err; } /**< Returns current error string */ + void menu(const bool post) { _auxUpdate->menu(post); }; /**< Enabel or disable arranging a created AutoConnectOTA page in the menu. */ + AC_OTAStatus_t status(void) const { return _status; } /**< Return current error status of the Update class */ + void setTicker(int8_t pin, uint8_t on) { _tickerPort = pin, _tickerOn = on; } /**< Set ticker LED port */ protected: // Attribute definition of the element to be placed on the update page. @@ -72,7 +73,7 @@ class AutoConnectOTA : public AutoConnectUploadHandler { void _setError(void); AC_OTAStatus_t _status; /**< Status for update progress */ - uint8_t _tickerPort; /**< GPIO for flicker */ + int8_t _tickerPort; /**< GPIO for flicker */ uint8_t _tickerOn; /**< A signal for flicker turn on */ String _binName; /**< An updater file name */ String _err; /**< Occurred error stamp */