Added AC_ONBOOTURI_PORTAL option

pull/197/head
Hieromon Ikasamo 4 years ago
parent 52b7b21526
commit 2eab4c78ce
  1. 11
      src/AutoConnect.cpp
  2. 5
      src/AutoConnect.h

@ -311,8 +311,13 @@ bool AutoConnect::_configSTA(const IPAddress& ip, const IPAddress& gateway, cons
return rc;
}
String AutoConnect::_getBootUri()
{
/**
* Get URI to redirect at boot. It uses the URI according to the
* AutoConnectConfig::bootUti setting with the AutoConnectConfig::homeUri
* as the boot path.
* @return the boot uri.
*/
String AutoConnect::_getBootUri(void) const {
if (_apConfig.bootUri == AC_ONBOOTURI_ROOT)
return String(AUTOCONNECT_URI);
else if (_apConfig.bootUri == AC_ONBOOTURI_HOME)
@ -685,7 +690,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() + _getBootUri();
String location = String(F("http://")) + _webServer->client().localIP().toString() + (_apConfig.bootUri == AC_ONBOOTURI_PORTAL ? _getBootUri() : String(AUTOCONNECT_URI));
_webServer->sendHeader(String(F("Location")), location, true);
_webServer->send(302, String(F("text/plain")), _emptyString);
_webServer->client().flush();

@ -47,7 +47,8 @@ typedef enum AC_SAVECREDENTIAL {
typedef enum AC_ONBOOTURI {
AC_ONBOOTURI_ROOT,
AC_ONBOOTURI_HOME
AC_ONBOOTURI_HOME,
AC_ONBOOTURI_PORTAL
} AC_ONBOOTURI_t;
class AutoConnectConfig {
@ -224,7 +225,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();
String _getBootUri(void) const;
bool _getConfigSTA(station_config_t* config);
void _startWebServer(void);
void _startDNSServer(void);

Loading…
Cancel
Save