Improved code readability

pull/41/head
Hieromon Ikasamo 6 years ago
parent 48c6ea8b4e
commit c428a33aa9
  1. 1
      src/AutoConnect.cpp
  2. 1
      src/AutoConnect.h
  3. 5
      src/AutoConnectDefs.h
  4. 21
      src/AutoConnectPage.cpp

@ -706,7 +706,6 @@ String AutoConnect::_induceConnect(PageArgument& args) {
// Turn on the trigger to start WiFi.begin(). // Turn on the trigger to start WiFi.begin().
_rfConnect = true; _rfConnect = true;
_menuTitle = String(F(AUTOCONNECT_CONNECTING_TITLE));
// Since v0.9.7, the redirect method changed from a 302 response to the // Since v0.9.7, the redirect method changed from a 302 response to the
// meta tag with refresh attribute. // meta tag with refresh attribute.

@ -336,7 +336,6 @@ class AutoConnect {
String _token_UPTIME(PageArgument& args); String _token_UPTIME(PageArgument& args);
String _token_BOOTURI(PageArgument& args); String _token_BOOTURI(PageArgument& args);
String _token_CURRENT_SSID(PageArgument& args); String _token_CURRENT_SSID(PageArgument& args);
String _token_RESULT_URI(PageArgument& args);
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
friend class ESP8266WebServer; friend class ESP8266WebServer;

@ -76,11 +76,6 @@
#define AUTOCONNECT_MENU_TITLE "AutoConnect" #define AUTOCONNECT_MENU_TITLE "AutoConnect"
#endif // !AUTOCONNECT_MENU_TITLE #endif // !AUTOCONNECT_MENU_TITLE
// AutoConnect title for during a connection attempting
#ifndef AUTOCONNECT_CONNECTING_TITLE
#define AUTOCONNECT_CONNECTING_TITLE "Connecting"
#endif // !AUTOCONNECT_CONNECTING_TITLE
// URIs of AutoConnect menu collection // URIs of AutoConnect menu collection
#define AUTOCONNECT_URI_CONFIG AUTOCONNECT_URI "/config" #define AUTOCONNECT_URI_CONFIG AUTOCONNECT_URI "/config"
#define AUTOCONNECT_URI_CONNECT AUTOCONNECT_URI "/connect" #define AUTOCONNECT_URI_CONNECT AUTOCONNECT_URI "/connect"

@ -3,7 +3,7 @@
* @file AutoConnectPage.h * @file AutoConnectPage.h
* @author hieromon@gmail.com * @author hieromon@gmail.com
* @version 0.9.7 * @version 0.9.7
* @date 2018-11-17 * @date 2019-01-23
* @copyright MIT license. * @copyright MIT license.
*/ */
@ -550,7 +550,7 @@ const char AutoConnect::_PAGE_404[] PROGMEM = {
/**< The page that started the reset. */ /**< The page that started the reset. */
const char AutoConnect::_PAGE_RESETTING[] PROGMEM = { const char AutoConnect::_PAGE_RESETTING[] PROGMEM = {
"{{HEAD}}" "{{HEAD}}"
"<meta http-equiv=\"refresh\" content=\"{{UPTIME}};URL={{BOOTURI}}\">" "<meta http-equiv=\"refresh\" content=\"{{UPTIME}};url={{BOOTURI}}\">"
"<title>AutoConnect resetting</title>" "<title>AutoConnect resetting</title>"
"</head>" "</head>"
"<body>" "<body>"
@ -711,7 +711,7 @@ const char AutoConnect::_PAGE_OPENCREDT[] PROGMEM = {
const char AutoConnect::_PAGE_CONNECTING[] PROGMEM = { const char AutoConnect::_PAGE_CONNECTING[] PROGMEM = {
"{{REQ}}" "{{REQ}}"
"{{HEAD}}" "{{HEAD}}"
"<meta http-equiv=\"refresh\" content=\"0;url=http://{{URI_RESULT}}\">" "<meta http-equiv=\"refresh\" content=\"0;url=" AUTOCONNECT_URI_RESULT "\">"
"<title>AutoConnect connecting</title>" "<title>AutoConnect connecting</title>"
"<style type=\"text/css\">" "<style type=\"text/css\">"
"{{CSS_BASE}}" "{{CSS_BASE}}"
@ -721,7 +721,7 @@ const char AutoConnect::_PAGE_CONNECTING[] PROGMEM = {
"<script type=\"text/javascript\">" "<script type=\"text/javascript\">"
"setTimeout(\"link()\"," AUTOCONNECT_RESPONSEREQUEST_TIMEOUT ");" "setTimeout(\"link()\"," AUTOCONNECT_RESPONSEREQUEST_TIMEOUT ");"
"function link(){" "function link(){"
"location.href='http://{{URI_RESULT}}';" "location.href='" AUTOCONNECT_URI_RESULT "';"
"</script>" "</script>"
"</head>" "</head>"
"<body style=\"padding-top:58px;\">" "<body style=\"padding-top:58px;\">"
@ -732,6 +732,8 @@ const char AutoConnect::_PAGE_CONNECTING[] PROGMEM = {
"<div style=\"position:absolute;left:-100%;right:-100%;text-align:center;margin:10px auto;font-weight:bold;color:#4169e1;\">{{CUR_SSID}}</div>" "<div style=\"position:absolute;left:-100%;right:-100%;text-align:center;margin:10px auto;font-weight:bold;color:#4169e1;\">{{CUR_SSID}}</div>"
"<div class=\"double-bounce1\"></div>" "<div class=\"double-bounce1\"></div>"
"<div class=\"double-bounce2\"></div>" "<div class=\"double-bounce2\"></div>"
"</div>"
"</div>"
"</body>" "</body>"
"</html>" "</html>"
}; };
@ -832,8 +834,8 @@ const char AutoConnect::_PAGE_DISCONN[] PROGMEM = {
"<body style=\"padding-top:58px;\">" "<body style=\"padding-top:58px;\">"
"<div class=\"container\">" "<div class=\"container\">"
"{{MENU_PRE}}" "{{MENU_PRE}}"
"{{MENU_AUX}}"
"{{MENU_POST}}" "{{MENU_POST}}"
"</div>"
"</body>" "</body>"
"</html>" "</html>"
}; };
@ -1172,11 +1174,6 @@ String AutoConnect::_token_CURRENT_SSID(PageArgument& args) {
return String(reinterpret_cast<char*>(_credential.ssid)); return String(reinterpret_cast<char*>(_credential.ssid));
} }
String AutoConnect::_token_RESULT_URI(PageArgument& args) {
AC_UNUSED(args);
return _webServer->client().localIP().toString() + String(AUTOCONNECT_URI_RESULT);
}
/** /**
* This function dynamically build up the response pages that conform to * This function dynamically build up the response pages that conform to
* the requested URI. A PageBuilder instance is stored in _rensponsePage * the requested URI. A PageBuilder instance is stored in _rensponsePage
@ -1239,10 +1236,10 @@ PageElement* AutoConnect::_setupPage(String uri) {
else if (uri == String(AUTOCONNECT_URI_CONNECT)) { else if (uri == String(AUTOCONNECT_URI_CONNECT)) {
// Setup /auto/connect // Setup /auto/connect
_menuTitle = FPSTR("Connecting");
elm->setMold(_PAGE_CONNECTING); elm->setMold(_PAGE_CONNECTING);
elm->addToken(String(FPSTR("REQ")), std::bind(&AutoConnect::_induceConnect, this, std::placeholders::_1)); elm->addToken(String(FPSTR("REQ")), std::bind(&AutoConnect::_induceConnect, this, std::placeholders::_1));
elm->addToken(String(FPSTR("HEAD")), std::bind(&AutoConnect::_token_HEAD, this, std::placeholders::_1)); elm->addToken(String(FPSTR("HEAD")), std::bind(&AutoConnect::_token_HEAD, this, std::placeholders::_1));
elm->addToken(String(FPSTR("URI_RESULT")), std::bind(&AutoConnect::_token_RESULT_URI, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1)); elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_SPINNER")), std::bind(&AutoConnect::_token_CSS_SPINNER, this, std::placeholders::_1)); elm->addToken(String(FPSTR("CSS_SPINNER")), std::bind(&AutoConnect::_token_CSS_SPINNER, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_LUXBAR")), std::bind(&AutoConnect::_token_CSS_LUXBAR, this, std::placeholders::_1)); elm->addToken(String(FPSTR("CSS_LUXBAR")), std::bind(&AutoConnect::_token_CSS_LUXBAR, this, std::placeholders::_1));
@ -1274,7 +1271,6 @@ PageElement* AutoConnect::_setupPage(String uri) {
elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1)); elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_LUXBAR")), std::bind(&AutoConnect::_token_CSS_LUXBAR, this, std::placeholders::_1)); elm->addToken(String(FPSTR("CSS_LUXBAR")), std::bind(&AutoConnect::_token_CSS_LUXBAR, this, std::placeholders::_1));
elm->addToken(String(FPSTR("MENU_PRE")), std::bind(&AutoConnect::_token_MENU_PRE, this, std::placeholders::_1)); elm->addToken(String(FPSTR("MENU_PRE")), std::bind(&AutoConnect::_token_MENU_PRE, this, std::placeholders::_1));
elm->addToken(String(FPSTR("MENU_AUX")), std::bind(&AutoConnect::_token_MENU_AUX, this, std::placeholders::_1));
elm->addToken(String(FPSTR("MENU_POST")), std::bind(&AutoConnect::_token_MENU_POST, this, std::placeholders::_1)); elm->addToken(String(FPSTR("MENU_POST")), std::bind(&AutoConnect::_token_MENU_POST, this, std::placeholders::_1));
} }
else if (uri == String(AUTOCONNECT_URI_RESET)) { else if (uri == String(AUTOCONNECT_URI_RESET)) {
@ -1315,6 +1311,7 @@ PageElement* AutoConnect::_setupPage(String uri) {
else if (uri == String(AUTOCONNECT_URI_FAIL)) { else if (uri == String(AUTOCONNECT_URI_FAIL)) {
// Setup /auto/fail // Setup /auto/fail
_menuTitle = FPSTR("Failed");
elm->setMold(_PAGE_FAIL); elm->setMold(_PAGE_FAIL);
elm->addToken(String(FPSTR("HEAD")), std::bind(&AutoConnect::_token_HEAD, this, std::placeholders::_1)); elm->addToken(String(FPSTR("HEAD")), std::bind(&AutoConnect::_token_HEAD, this, std::placeholders::_1));
elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1)); elm->addToken(String(FPSTR("CSS_BASE")), std::bind(&AutoConnect::_token_CSS_BASE, this, std::placeholders::_1));

Loading…
Cancel
Save