diff --git a/src/AutoConnectLabels.h b/src/AutoConnectLabels.h index ae57491..60dab91 100644 --- a/src/AutoConnectLabels.h +++ b/src/AutoConnectLabels.h @@ -62,9 +62,9 @@ #endif // !AUTOCONNECT_MENULABEL_UPDATE // Menu item: Device Info -#ifndef AUTOCONNECT_MENULABEL_DEVICEINFO -#define AUTOCONNECT_MENULABEL_DEVICEINFO "Device info" -#endif // !AUTOCONNECT_MENULABEL_DEVICEINFO +#ifndef AUTOCONNECT_MENULABEL_DEVINFO +#define AUTOCONNECT_MENULABEL_DEVINFO "Device info" +#endif // !AUTOCONNECT_MENULABEL_DEVINFO // Button label: RESET #ifndef AUTOCONNECT_BUTTONLABEL_RESET diff --git a/src/AutoConnectPage.cpp b/src/AutoConnectPage.cpp index 21a16a5..93d641a 100644 --- a/src/AutoConnectPage.cpp +++ b/src/AutoConnectPage.cpp @@ -1366,35 +1366,52 @@ String AutoConnect::_token_CURRENT_SSID(PageArgument& args) { * @return HTML string of a li tag with the menu item. */ String AutoConnect::_attachMenuItem(const AC_MENUITEM_t item) { - AC_MENUITEM_t liItem = static_cast(_apConfig.attachMenu & static_cast(item)); - String li = String(F("
  • " AUTOCONNECT_MENULABEL_RESET)); - else { - li += String(F(">" AUTOCONNECT_MENULABEL_CONFIGNEW)); - break; - case AC_MENUITEM_OPENSSIDS: - li += String(F(AUTOCONNECT_URI_OPEN "\">" AUTOCONNECT_MENULABEL_OPENSSIDS)); - break; - case AC_MENUITEM_DISCONNECT: - li += String(F(AUTOCONNECT_URI_DISCON "\">" AUTOCONNECT_MENULABEL_DISCONNECT)); - break; - case AC_MENUITEM_DEVINFO: - li += String(F(AUTOCONNECT_URI "\">" AUTOCONNECT_MENULABEL_DEVICEINFO)); - break; - case AC_MENUITEM_HOME: - li += String(F("HOME_URI\">" AUTOCONNECT_MENULABEL_HOME)); - break; - default: - li = _emptyString; - break; - } + static const char _liTempl[] PROGMEM = "
  • %s
  • "; + PGM_P id; + PGM_P link; + PGM_P label; + + switch (static_cast(_apConfig.attachMenu & static_cast(item))) { + case AC_MENUITEM_CONFIGNEW: + id = PSTR(""); + link = PSTR(AUTOCONNECT_URI_CONFIG); + label = PSTR(AUTOCONNECT_MENULABEL_CONFIGNEW); + break; + case AC_MENUITEM_OPENSSIDS: + id = PSTR(""); + link = PSTR(AUTOCONNECT_URI_OPEN); + label = PSTR(AUTOCONNECT_MENULABEL_OPENSSIDS); + break; + case AC_MENUITEM_DISCONNECT: + id = PSTR(""); + link = PSTR(AUTOCONNECT_URI_DISCON); + label = PSTR(AUTOCONNECT_MENULABEL_DISCONNECT); + break; + case AC_MENUITEM_RESET: + id = PSTR(" id=\"reset\""); + link = PSTR("#rdlg"); + label = PSTR(AUTOCONNECT_MENULABEL_RESET); + break; + case AC_MENUITEM_HOME: + id = PSTR(""); + link = PSTR("HOME_URI"); + label = PSTR(AUTOCONNECT_MENULABEL_HOME); + break; + case AC_MENUITEM_DEVINFO: + id = PSTR(""); + link = PSTR(AUTOCONNECT_URI); + label = PSTR(AUTOCONNECT_MENULABEL_DEVINFO); + break; + default: + id = nullptr; + link = nullptr; + label = nullptr; + break; } - li += String(F("")); - return li; + char li[128] = { '\0' }; + if (!!id && !!link && !!label) + snprintf(li, sizeof(li), (PGM_P)_liTempl, id, link, label); + return String(li); } /**