From 7882c0e9a9af6e5b814c2449fb72016675125258 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 29 Nov 2019 19:54:02 -0600 Subject: [PATCH] fixes #975 --- WiFiManager.cpp | 14 +++++++++++++- WiFiManager.h | 3 +++ .../OnDemandConfigPortal/OnDemandConfigPortal.ino | 4 +++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index a34a28a..90b2d41 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1031,7 +1031,7 @@ String WiFiManager::getMenuOut(){ String page; for(auto menuId :_menuIds ){ - if(((String)menuId == "param") && (_paramsCount == 0)) continue; // no params set, omit params + if(((String)menuId == "param") && (_paramsCount == 0)) continue; // no params set, omit params from menu, @todo this may be undesired by someone page += HTTP_PORTAL_MENU[menuId]; } @@ -2375,6 +2375,18 @@ void WiFiManager::setMenu(std::vector& menu){ } +/** + * set params as sperate page not in wifi + * NOT COMPATIBLE WITH setMenu! @todo scan menuids and insert param after wifi or something + * @param bool enable + * @since $dev + */ +void WiFiManager::setParamsPage(bool enable){ + _paramsInWifi= false; + _menuIdsDefault = {"wifi","param","info","exit"}; + setMenu(_menuIdsDefault); +} + // GETTERS /** diff --git a/WiFiManager.h b/WiFiManager.h index 9af9c03..9691135 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -266,6 +266,9 @@ class WiFiManager // set custom menu items and order void setMenu(std::vector& menu); void setMenu(const char* menu[], uint8_t size); + + // add params to its own menu page and remove from wifi, NOT TO BE COMBINED WITH setMenu! + void setParamsPage(bool enable); // get last connection result, includes autoconnect and wifisave uint8_t getLastConxResult(); diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index d9582d4..4eff3b7 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -172,8 +172,10 @@ void setup() { // wm.setMenu(menu,9); // custom menu array must provide length std::vector menu = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"}; - wm.setMenu(menu); // custom menu, pass vector + // wm.setMenu(menu); // custom menu, pass vector + // wm.setParamsPage(true); // move params to seperate page, not wifi + // set static sta ip // wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); // wm.setShowStaticFields(false);