From 809f8c7d1fb87e623985308f0bff4c064f6f4db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 20 Feb 2017 21:27:56 +0100 Subject: [PATCH] Using espurna.local when in AP mode. Removed captive portal --- code/espurna/config/general.h | 4 ---- code/espurna/wifi.ino | 26 +++----------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index a6596af2..df79c99d 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -92,16 +92,12 @@ #define WS_TIMEOUT 1800000 #define WEBSERVER_PORT 80 #define DNS_PORT 53 -#define ENABLE_CAPTIVE_PORTAL 0 #define ENABLE_MDNS 1 #define WEB_MODE_NORMAL 0 #define WEB_MODE_PASSWORD 1 #define AP_MODE AP_MODE_ALONE -#define AP_MODE_IP "192.168.4.1" -#define AP_MODE_GW "192.168.4.1" -#define AP_MODE_MASK "255.255.255.0" // This option builds the firmware with the web interface embedded. // You first have to build the data.h file that holds the contents diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 14a20de3..4c163419 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -8,11 +8,6 @@ Copyright (C) 2016-2017 by Xose PĂ©rez #include "JustWifi.h" -#if ENABLE_CAPTIVE_PORTAL -#include -DNSServer dnsServer; -#endif - // ----------------------------------------------------------------------------- // WIFI // ----------------------------------------------------------------------------- @@ -55,7 +50,7 @@ bool createAP() { void wifiConfigure() { jw.setHostname(getSetting("hostname", HOSTNAME).c_str()); - jw.setSoftAP(getSetting("hostname", HOSTNAME).c_str(), getSetting("adminPass", ADMIN_PASS).c_str(), AP_MODE_IP, AP_MODE_GW, AP_MODE_MASK); + jw.setSoftAP(getSetting("hostname", HOSTNAME).c_str(), getSetting("adminPass", ADMIN_PASS).c_str()); jw.setAPMode(AP_MODE); jw.cleanNetworks(); @@ -183,8 +178,8 @@ void wifiSetup() { // Configure mDNS #if ENABLE_MDNS - if (code == MESSAGE_CONNECTED) { - if (MDNS.begin((char *) WiFi.hostname().c_str())) { + if (code == MESSAGE_CONNECTED || code == MESSAGE_ACCESSPOINT_CREATED) { + if (MDNS.begin(WiFi.getMode() == WIFI_AP ? APP_NAME : (char *) WiFi.hostname().c_str())) { MDNS.addService("http", "tcp", 80); DEBUG_MSG_P(PSTR("[MDNS] OK\n")); } else { @@ -193,16 +188,6 @@ void wifiSetup() { } #endif - // Configure captive portal - #if ENABLE_CAPTIVE_PORTAL - if (code == MESSAGE_ACCESSPOINT_CREATED) { - dnsServer.start(DNS_PORT, "*", WiFi.softAPIP()); - } - if (code == MESSAGE_DISCONNECTED) { - dnsServer.stop(); - } - #endif - // NTP connection reset if (code == MESSAGE_CONNECTED) { ntpConnect(); @@ -225,9 +210,4 @@ void wifiSetup() { void wifiLoop() { jw.loop(); - #if ENABLE_CAPTIVE_PORTAL - if (WiFi.getMode() == WIFI_AP) { - dnsServer.processNextRequest(); - } - #endif }