Supports AutoConnectLabels

pull/57/head
Hieromon Ikasamo 5 years ago
parent 3c0c1da99b
commit 8b3036f89c
  1. 13
      mkdocs/advancedusage.md
  2. 2
      src/AutoConnect.cpp
  3. 65
      src/AutoConnectLabels.h
  4. 15
      src/AutoConnectPage.cpp
  5. 2
      src/AutoConnectPage.h

@ -191,6 +191,19 @@ Executing the above sketch will rewrite the menu title for the **FSBrowser** as
<div style="float:left;width:40%;height:470px;overflow:hidden;"><img src="images/fsbmenu.png"></div>
<img style="margin-left:70px;width:40%;height:470px;" src="images/fsbmenu_expand.png">
### <i class="fa fa-caret-right"></i> Change the menu labels
You can change the label of the AutoConnect menu item by rewriting the default label letter in [AutoConnectLabels.h](https://github.com/Hieromon/AutoConnect/blob/master/src/AutoConnectLabels.h) macros. However, changing menu items letter influences all the sketch's build scenes.
```cpp
#define AUTOCONNECT_MENULABEL_CONFIGNEW "Configure new AP"
#define AUTOCONNECT_MENULABEL_OPENSSIDS "Open SSIDs"
#define AUTOCONNECT_MENULABEL_DISCONNECT "Disconnect"
#define AUTOCONNECT_MENULABEL_RESET "Reset..."
#define AUTOCONNECT_MENULABEL_HOME "HOME"
#define AUTOCONNECT_BUTTONLABEL_RESET "RESET"
```
### <i class="fa fa-caret-right"></i> Combination with mDNS
With [mDNS library](https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS), you can access to ESP8266 by name instead of IP address after connection. The sketch can start the MDNS responder after [*AutoConnect::begin*](api.md#begin).

@ -668,7 +668,7 @@ void AutoConnect::_handleNotFound(void) {
String AutoConnect::_induceReset(PageArgument& args) {
AC_UNUSED(args);
_rfReset = true;
return String(F("Reset in progress..."));
return String(F(AUTOCONNECT_BUTTONLABEL_RESET " in progress..."));
}
/**

@ -0,0 +1,65 @@
/**
* AutoConnect proper menu label constant definition.
* @file AutoConnectLabels.h
* @author hieromon@gmail.com
* @version 0.9.8
* @date 2019-03-11
* @copyright MIT license.
*/
#ifndef _AUTOCONNECTLABELS_H_
#define _AUTOCONNECTLABELS_H_
/**
* The upper row of each of the following definition items is the
* default value. The lower row is an alternative label string as
* a sample and can be changed you wish.
*
* Notes:
* You can find some tokens for the PageBuilder if you parse
* AutoConnectPage.cpp. Some of the tokens are valid at the time
* the AutoConnect menu will generate. For example, the token
* `{{CUR_SSID}}` returns the SSID of the currently participating
* AP by AutoConnect::_token_CURRENT_SSID function.
* You can use these tokens to display dynamic menus showing the
* current situation, but you need to know the internal structure
* of AutoConnect in order to display the appropriate menu.
*/
// Menu item: Configure new AP
#ifndef AUTOCONNECT_MENULABEL_CONFIGNEW
#define AUTOCONNECT_MENULABEL_CONFIGNEW "Configure new AP"
//#define AUTOCONNECT_MENULABEL_CONFIGNEW "Establish a new AP"
#endif // !AUTOCONNECT_MENULABEL_CONFIGNEW
// Menu item: Open SSIDs
#ifndef AUTOCONNECT_MENULABEL_OPENSSIDS
#define AUTOCONNECT_MENULABEL_OPENSSIDS "Open SSIDs"
//#define AUTOCONNECT_MENULABEL_OPENSSIDS "Open credentials"
#endif // !AUTOCONNECT_MENULABEL_OPENSSIDS
// Menu item: Disconnect
#ifndef AUTOCONNECT_MENULABEL_DISCONNECT
#define AUTOCONNECT_MENULABEL_DISCONNECT "Disconnect"
//#define AUTOCONNECT_MENULABEL_DISCONNECT "Leave {{CUR_SSID}}"
#endif // !AUTOCONNECT_MENULABEL_DISCONNECT
// Menu item: Reset...
#ifndef AUTOCONNECT_MENULABEL_RESET
#define AUTOCONNECT_MENULABEL_RESET "Reset..."
//#define AUTOCONNECT_MENULABEL_RESET "Reboot..."
#endif // !AUTOCONNECT_MENULABEL_RESET
// Menu item: HOME
#ifndef AUTOCONNECT_MENULABEL_HOME
#define AUTOCONNECT_MENULABEL_HOME "HOME"
//#define AUTOCONNECT_MENULABEL_HOME "Main"
#endif // !AUTOCONNECT_MENULABEL_HOME
// Button label: RESET
#ifndef AUTOCONNECT_BUTTONLABEL_RESET
#define AUTOCONNECT_BUTTONLABEL_RESET "RESET"
//#define AUTOCONNECT_BUTTONLABEL_RESET "Reboot"
#endif // !AUTOCONNECT_BUTTONLABEL_RESET
#endif

@ -525,10 +525,10 @@ const char AutoConnect::_ELM_MENU_PRE[] PROGMEM = {
"<a href=\"" AUTOCONNECT_URI "\" class=\"luxbar-brand\">MENU_TITLE</a>"
"<label class=\"luxbar-hamburger luxbar-hamburger-doublespin\" id=\"luxbar-hamburger\" for=\"luxbar-checkbox\"><span></span></label>"
"</li>"
"<li class=\"luxbar-item\"><a href=\"" AUTOCONNECT_URI_CONFIG "\">Configure new AP</a></li>"
"<li class=\"luxbar-item\"><a href=\"" AUTOCONNECT_URI_OPEN "\">Open SSIDs</a></li>"
"<li class=\"luxbar-item\"><a href=\"" AUTOCONNECT_URI_DISCON "\">Disconnect</a></li>"
"<li class=\"luxbar-item\" id=\"reset\"><a href=\"#rdlg\">Reset...</a></li>"
"<li class=\"luxbar-item\"><a href=\"" AUTOCONNECT_URI_CONFIG "\">" AUTOCONNECT_MENULABEL_CONFIGNEW "</a></li>"
"<li class=\"luxbar-item\"><a href=\"" AUTOCONNECT_URI_OPEN "\">" AUTOCONNECT_MENULABEL_OPENSSIDS "</a></li>"
"<li class=\"luxbar-item\"><a href=\"" AUTOCONNECT_URI_DISCON "\">" AUTOCONNECT_MENULABEL_DISCONNECT "</a></li>"
"<li class=\"luxbar-item\" id=\"reset\"><a href=\"#rdlg\">" AUTOCONNECT_MENULABEL_RESET "</a></li>"
};
const char AutoConnect::_ELM_MENU_AUX[] PROGMEM = {
@ -536,11 +536,11 @@ const char AutoConnect::_ELM_MENU_AUX[] PROGMEM = {
};
const char AutoConnect::_ELM_MENU_POST[] PROGMEM = {
"<li class=\"luxbar-item\"><a href=\"HOME_URI\">HOME</a></li>"
"<li class=\"luxbar-item\"><a href=\"HOME_URI\">" AUTOCONNECT_MENULABEL_HOME "</a></li>"
"</ul>"
"</div>"
"<div class=\"lap\" id=\"rdlg\"><a href=\"#reset\" class=\"overlap\"></a>"
"<div class=\"modal_button\"><h2><a href=\"" AUTOCONNECT_URI_RESET "\" class=\"modal_button\">RESET</a></h2></div>"
"<div class=\"modal_button\"><h2><a href=\"" AUTOCONNECT_URI_RESET "\" class=\"modal_button\">" AUTOCONNECT_BUTTONLABEL_RESET "</a></h2></div>"
"</div>"
"</header>"
};
@ -906,10 +906,9 @@ String AutoConnect::_token_HEAD(PageArgument& args) {
}
String AutoConnect::_token_MENU_PRE(PageArgument& args) {
AC_UNUSED(args);
String currentMenu = FPSTR(_ELM_MENU_PRE);
currentMenu.replace(String(F("MENU_TITLE")), _menuTitle);
// currentMenu.replace(String(F("HOME_URI")), _apConfig.homeUri);
currentMenu.replace(String(F("{{CUR_SSID}}")), _token_ESTAB_SSID(args));
return currentMenu;
}

@ -10,6 +10,8 @@
#ifndef _AUTOCONNECTPAGE_H_
#define _AUTOCONNECTPAGE_H_
#include "AutoConnectLabels.h"
#define AUTOCONNECT_PARAMID_SSID "SSID"
#define AUTOCONNECT_PARAMID_PASS "Passphrase"
#define AUTOCONNECT_PARAMID_CRED "Credential"

Loading…
Cancel
Save