Added Captive Portal DNS server for AP

Fixed overlay and AP password bugs
pull/46/head
cschwinne 2018-03-14 11:41:24 +01:00
rodzic 37f91c4d50
commit 3ef4a2b9d2
11 zmienionych plików z 55 dodań i 28 usunięć

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -22,6 +22,7 @@
#include <EEPROM.h>
#include <ArduinoOTA.h>
#include <WiFiUDP.h>
#include <DNSServer.h>
#include "src/dependencies/webserver/ESP8266HTTPUpdateServer.h"
#include "src/dependencies/time/Time.h"
#include "src/dependencies/time/TimeLib.h"
@ -32,7 +33,7 @@
#include "WS2812FX.h"
//version in format yymmddb (b = daily build)
#define VERSION 1803141
#define VERSION 1803142
const String versionString = "0.6.0_dev";
//AP and OTA default passwords (change them!)
@ -59,7 +60,7 @@ uint8_t auxTriggeredState = 0; //0: input 1: high 2: low
String serverDescription = versionString;
uint8_t currentTheme = 0;
String clientssid = "Your_Network_Here";
String clientpass = "Dummy_Pass";
String clientpass = "";
String cmdns = "led";
uint8_t ledcount = 10; //lowered to prevent accidental overcurrent
String apssid = ""; //AP off by default (unless setup)
@ -229,6 +230,10 @@ unsigned int portMulti = 1900;
char packetBuffer[255];
String escapedMac;
//dns server
DNSServer dnsServer;
bool dnsActive = false;
#ifdef ARDUINO_ARCH_ESP32
WebServer server(80);
#else
@ -317,6 +322,7 @@ void loop() {
handleOverlays();
if (!arlsTimeout) //block stuff if WARLS is enabled
{
if (dnsActive) dnsServer.processNextRequest();
handleHue();
handleNightlight();
if (bri_t) strip.service(); //do not update strip if off, prevents flicker on ESP32

Wyświetl plik

@ -97,7 +97,7 @@ String getSettings(uint8_t subPage)
resp += ds + "APSSID" + v + "\"" + apssid + "\";";
resp += ds + "APHSSID" + c + aphide + ";";
resp += ds + "APPASS" + v + "\"";
for (int i = 0; i < clientpass.length(); i++)
for (int i = 0; i < appass.length(); i++)
{
resp += "*";
}

Wyświetl plik

@ -231,6 +231,7 @@ void handleSettingsSet(uint8_t subPage)
}
nightlightFade = server.hasArg("TLFDE");
reverseMode = server.hasArg("LEDRV");
strip.setReverseMode(reverseMode);
if (server.hasArg("WOFFS"))
{
int i = server.arg("WOFFS").toInt();

Wyświetl plik

@ -77,6 +77,14 @@ void wledInit()
if (ntpEnabled && WiFi.status() == WL_CONNECTED)
ntpConnected = ntpUdp.begin(ntpLocalPort);
//start captive portal
if (onlyAP || apssid.length() > 0)
{
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
dnsServer.start(53, "*", WiFi.softAPIP());
dnsActive = true;
}
//SERVER INIT
//settings page
server.on("/settings", HTTP_GET, [](){
@ -114,15 +122,15 @@ void wledInit()
});
server.on("/", HTTP_GET, [](){
if (!showWelcomePage){
if(!handleFileRead("/index.htm")) {
serveIndex();
}
}else{
if(!handleFileRead("/welcome.htm")) {
serveSettings(255);
}
}
serveIndexOrWelcome();
});
server.on("/generate_204", HTTP_GET, [](){
serveIndexOrWelcome();
});
server.on("/fwlink", HTTP_GET, [](){
serveIndexOrWelcome();
});
server.on("/sliders", HTTP_GET, serveIndex);
@ -375,6 +383,19 @@ void buildCssColorString()
cssColorString+=";}";
}
void serveIndexOrWelcome()
{
if (!showWelcomePage){
if(!handleFileRead("/index.htm")) {
serveIndex();
}
}else{
if(!handleFileRead("/welcome.htm")) {
serveSettings(255);
}
}
}
void serveIndex()
{
if (!arlsTimeout) //do not serve while receiving realtime

Wyświetl plik

@ -137,7 +137,8 @@ void handleOverlays()
void _overlaySolid()
{
uint32_t cls = (useGammaCorrectionRGB)? gamma8[white*16777216] + gamma8[col[0]]*65536 + gamma8[col[1]]*256 + gamma8[col[2]]:white*16777216 + col[0]*65536 + col[1]*256 + col[2];
strip.unlockAll();
uint32_t cls = (useGammaCorrectionRGB)? gamma8[white_sec*16777216] + gamma8[col_sec[0]]*65536 + gamma8[col_sec[1]]*256 + gamma8[col_sec[2]]:white_sec*16777216 + col_sec[0]*65536 + col_sec[1]*256 + col_sec[2];
strip.setRange(overlayMin,overlayMax,cls);
overlayRefreshMs = 1902;
}
@ -161,6 +162,17 @@ void _overlayAnalogClock()
if (minutePixel > overlayMax) minutePixel = overlayMin -1 + minutePixel - overlayMax;
int secondPixel = floor(analogClock12pixel + overlaySize*secondP);
if (secondPixel > overlayMax) secondPixel = overlayMin -1 + secondPixel - overlayMax;
if (analogClockSecondsTrail)
{
if (secondPixel < analogClock12pixel)
{
strip.setRange(analogClock12pixel, overlayMax, 0xFF0000);
strip.setRange(overlayMin, secondPixel, 0xFF0000);
} else
{
strip.setRange(analogClock12pixel, secondPixel, 0xFF0000);
}
}
if (analogClock5MinuteMarks)
{
int pix;
@ -168,23 +180,10 @@ void _overlayAnalogClock()
{
pix = overlayMin + analogClock12pixel + (overlaySize/12)*i;
if (pix > overlayMax) pix = pix - overlayMax;
strip.setIndividual(pix, 0xAAAAAA);
strip.setIndividual(pix,0x00FFAA);
}
}
if (analogClockSecondsTrail)
{
if (secondPixel < analogClock12pixel)
{
strip.setRange(analogClock12pixel, secondPixel, 0xFF0000);
strip.setRange(secondPixel, overlayMax, 0xFF0000);
} else
{
strip.setRange(analogClock12pixel, secondPixel, 0xFF0000);
}
} else
{
strip.setIndividual(secondPixel, 0xFF0000);
}
if (!analogClockSecondsTrail) strip.setIndividual(secondPixel, 0xFF0000);
strip.setIndividual(minutePixel, 0x00FF00);
strip.setIndividual(hourPixel, 0x0000FF);
overlayRefreshMs = 998;