Browse Source

Using espurna.local when in AP mode. Removed captive portal

fastled
Xose Pérez 7 years ago
parent
commit
809f8c7d1f
2 changed files with 3 additions and 27 deletions
  1. +0
    -4
      code/espurna/config/general.h
  2. +3
    -23
      code/espurna/wifi.ino

+ 0
- 4
code/espurna/config/general.h View File

@ -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


+ 3
- 23
code/espurna/wifi.ino View File

@ -8,11 +8,6 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
#include "JustWifi.h"
#if ENABLE_CAPTIVE_PORTAL
#include <DNSServer.h>
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
}

Loading…
Cancel
Save