Browse Source

Captive portal when in AP mode

fastled
Xose Pérez 7 years ago
parent
commit
bd60635dd1
4 changed files with 18 additions and 0 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +1
    -0
      code/src/config/general.h
  3. +3
    -0
      code/src/main.ino
  4. +12
    -0
      code/src/wifi.ino

+ 2
- 0
CHANGELOG.md View File

@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added last-modified header to static contents
- Added support for multi-button boards (SONOFF_4CH)
- Added support for WorkChoice ecoPlug (ECOPLUG). Thanks to David Myers
- Added support for Sonoff SV
- Added DNS captive portal for AP mode
- Force password changing if it's the default one
- Comment out hardware selection in hardware.h if using Arduino IDE


+ 1
- 0
code/src/config/general.h View File

@ -37,6 +37,7 @@
#define HTTP_USERNAME "admin"
#define WS_BUFFER_SIZE 5
#define WS_TIMEOUT 1800000
#define DNS_PORT 53
// -----------------------------------------------------------------------------
// OTA & NOFUSS


+ 3
- 0
code/src/main.ino View File

@ -85,9 +85,12 @@ void welcome() {
DEBUG_MSG("%s\n%s\n\n", (char *) APP_AUTHOR, (char *) APP_WEBSITE);
//DEBUG_MSG("Device: %s\n", (char *) getIdentifier().c_str());
DEBUG_MSG("ChipID: %06X\n", ESP.getChipId());
DEBUG_MSG("CPU frequency: %d MHz\n", ESP.getCpuFreqMHz());
DEBUG_MSG("Last reset reason: %s\n", (char *) ESP.getResetReason().c_str());
DEBUG_MSG("Memory size: %d bytes\n", ESP.getFlashChipSize());
DEBUG_MSG("Free heap: %d bytes\n", ESP.getFreeHeap());
DEBUG_MSG("Firmware size: %d bytes\n", ESP.getSketchSize());
DEBUG_MSG("Free firmware space: %d bytes\n", ESP.getFreeSketchSpace());
FSInfo fs_info;
if (SPIFFS.info(fs_info)) {
DEBUG_MSG("File system total size: %d bytes\n", fs_info.totalBytes);


+ 12
- 0
code/src/wifi.ino View File

@ -8,6 +8,9 @@ Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
*/
#include "JustWifi.h"
#include <DNSServer.h>
DNSServer dnsServer;
// -----------------------------------------------------------------------------
// WIFI
@ -147,10 +150,19 @@ void wifiSetup() {
}
// Configure captive portal
if (code == MESSAGE_ACCESSPOINT_CREATED) {
dnsServer.start(DNS_PORT, "*", WiFi.softAPIP());
}
if (code == MESSAGE_DISCONNECTED) {
dnsServer.stop();
}
});
}
void wifiLoop() {
jw.loop();
dnsServer.processNextRequest();
}

Loading…
Cancel
Save