From 52b7b21526a1f604d6edf2784f3ca2c625bf1faf Mon Sep 17 00:00:00 2001 From: David Maixner Date: Sat, 15 Feb 2020 12:10:51 +0100 Subject: [PATCH] use booturi for new connection and for menu AutoConnect was displaying device statistics on every new connection. Now it should be able to display booturi, so user is able to use his page as boot page. This booturi is used as link for title of the menu too. --- src/AutoConnect.cpp | 12 +++++++++++- src/AutoConnect.h | 1 + src/AutoConnectPage.cpp | 10 +++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index 669f727..33efcb6 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -311,6 +311,16 @@ bool AutoConnect::_configSTA(const IPAddress& ip, const IPAddress& gateway, cons return rc; } +String AutoConnect::_getBootUri() +{ + if (_apConfig.bootUri == AC_ONBOOTURI_ROOT) + return String(AUTOCONNECT_URI); + else if (_apConfig.bootUri == AC_ONBOOTURI_HOME) + return _apConfig.homeUri.length() > 0 ? _apConfig.homeUri : String("/"); + else + return _emptyString; +} + /** * Obtains the currently established AP connection to determine if the * station configuration needs to run before the first WiFi.begin. @@ -675,7 +685,7 @@ bool AutoConnect::_captivePortal(void) { String hostHeader = _webServer->hostHeader(); if (!_isIP(hostHeader) && (hostHeader != WiFi.localIP().toString()) && (!hostHeader.endsWith(F(".local")))) { AC_DBG("Detected application, %s, %s\n", hostHeader.c_str(), WiFi.localIP().toString().c_str()); - String location = String(F("http://")) + _webServer->client().localIP().toString() + String(AUTOCONNECT_URI); + String location = String(F("http://")) + _webServer->client().localIP().toString() + _getBootUri(); _webServer->sendHeader(String(F("Location")), location, true); _webServer->send(302, String(F("text/plain")), _emptyString); _webServer->client().flush(); diff --git a/src/AutoConnect.h b/src/AutoConnect.h index 1f34f02..e275dbe 100644 --- a/src/AutoConnect.h +++ b/src/AutoConnect.h @@ -224,6 +224,7 @@ class AutoConnect { } AC_STARECONNECT_t; bool _config(void); bool _configSTA(const IPAddress& ip, const IPAddress& gateway, const IPAddress& netmask, const IPAddress& dns1, const IPAddress& dns2); + String _getBootUri(); bool _getConfigSTA(station_config_t* config); void _startWebServer(void); void _startDNSServer(void); diff --git a/src/AutoConnectPage.cpp b/src/AutoConnectPage.cpp index f69b99a..3afa18e 100644 --- a/src/AutoConnectPage.cpp +++ b/src/AutoConnectPage.cpp @@ -550,7 +550,7 @@ const char AutoConnect::_ELM_MENU_PRE[] PROGMEM = { "
" "