kludge setmenu with size so it works

Prboably going to add a vector for this, I do not want to add the overhead of std::array for something optional
This commit is contained in:
Shawn A
2018-03-16 14:18:48 -05:00
parent d07f73263a
commit e3b7dc2641
2 changed files with 12 additions and 9 deletions
+6 -5
View File
@@ -156,7 +156,6 @@ void WiFiManager::WiFiManagerInit(){
_usermode = WiFi.getMode();
WiFi.persistent(false); // disable persistent so scannetworks and mode switching do not cause overwrites
setMenu(_menuIds);
_max_params = WIFI_MANAGER_MAX_PARAMS;
}
@@ -810,7 +809,8 @@ String WiFiManager::getMenuOut(){
String page;
int i;
for(i=0;i<sizeof(_menuIds);i++){
if(_menuIds[i] == 255) continue;
DEBUG_WM(i,_menuIds[i]);
if(_menuIds[i] == MENU_END) break; // MENU_END
if((_menuIds[i] == MENU_PARAM) && (_paramsCount == 0)) continue; // no params set, omit params
page += HTTP_PORTAL_MENU[_menuIds[i]];
}
@@ -1889,12 +1889,13 @@ void WiFiManager::setShowInfoErase(boolean enabled){
* @since $dev
* @param uint8_t menu[] array of menu ids
*/
void WiFiManager::setMenu(uint8_t menu[]){
void WiFiManager::setMenu(menu_page_t menu[], uint8_t size){
int i;
int n = sizeof(menu);
size_t n = size;
for(i=0;i<sizeof(_menuIds);i++){
if(menu[i] == MENU_PARAM) _paramsInWifi = false; // param auto flag
_menuIds[i] = i < n-1 ? menu[i] : 255;
if(i >= n) _menuIds[i] = MENU_END;
else _menuIds[i] = menu[i];
}
}
+6 -4
View File
@@ -135,7 +135,8 @@ class WiFiManager
MENU_RESTART = 5,
MENU_EXIT = 6,
MENU_ERASE = 7,
MENU_SEP = 8
MENU_SEP = 8,
MENU_END = 255
} menu_page_t;
// auto connect to saved wifi, or custom, and start config portal on failures
@@ -219,7 +220,9 @@ class WiFiManager
// show erase wifi onfig button on info page, true
void setShowInfoErase(boolean enabled);
// set custom menu
void setMenu(uint8_t menu[]);
// void setMenu(const std:vector<menu_page_t>& menu);
void setMenu(menu_page_t menu[], uint8_t size);
// get last connection result, includes autoconnect and wifisave
uint8_t getLastConxResult();
@@ -250,8 +253,7 @@ class WiFiManager
DEBUG_MAX = 4
} wm_debuglevel_t;
// std:vector<uint8_t> _menuids;
uint8_t _menuIds[10] = {MENU_WIFI,MENU_INFO,MENU_EXIT};
menu_page_t _menuIds[10] = {MENU_WIFI,MENU_INFO,MENU_EXIT,MENU_END};
// ip configs @todo struct ?
IPAddress _ap_static_ip;