From 31dd40fa9ee85a74fe306f12b656cfaeaae80c4c Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 1 Feb 2017 21:25:09 +0100 Subject: [PATCH] Embedded HTML in sketch to make SPIFFS data upload optional --- readme.md | 4 +- wled00/htmls00.h | 219 +++++++++++++++++++++++++++++++++++++++++ wled00/htmls01.h | 210 +++++++++++++++++++++++++++++++++++++++ wled00/wled00.ino | 2 + wled00/wled05_init.ino | 8 +- 5 files changed, 438 insertions(+), 5 deletions(-) create mode 100644 wled00/htmls00.h create mode 100644 wled00/htmls01.h diff --git a/readme.md b/readme.md index 93666cde6..f264ee744 100644 --- a/readme.md +++ b/readme.md @@ -29,10 +29,12 @@ Quick start guide: 1. Make sure your ESP module has a min. 4MB SPI flash module. (currently working on supporting 1MB modules) Connect a WS2812B RGB led strip to GPIO2. Optionally connect a NO-pushbutton to GPIO0 (internal pull-up) and ground. -2. Follow a guide to setup your Arduino client (I am using version 1.6.9) with the ESP8266 libraries. +2. Follow a guide to setup your Arduino client (I am using version 1.8.1) with the ESP8266 libraries. For current compiles I use an old version from 15th August 2016. 3. You will also need the ESP8266 SPIFFS sketch data uploader. (currently working on making this step unnecessary) +-> In the newest commit this step is not essential (HTML included in sketch), but recommended, since otherwise you have to upload the pictures manually to /edit SPIFFS +-> The software will always use the HTML files in SPIFFS. If they are not existing, it will fallback to the sketch embedded HTML files. 4. In file "wled00.ino", change the LED count to the amount you connected. Proceed to flash the sketch and the SPIFFS data. You should also change the access point and OTA update passphrases for added security (you can change them later, this is just the "factory default"). diff --git a/wled00/htmls00.h b/wled00/htmls00.h new file mode 100644 index 000000000..e6d157f2b --- /dev/null +++ b/wled00/htmls00.h @@ -0,0 +1,219 @@ +/* + * Index html + */ +const char PAGE_index[] PROGMEM = R"=====( + + + WLED 0.3pd + + + + +
+ + +
+
+
+
+
+

+
+

+
+

+
+

+
+
+ +)====="; +/* + * SPIFFS editor html + */ +const char PAGE_edit[] PROGMEM = R"=====( +ESP Editor
+)====="; diff --git a/wled00/htmls01.h b/wled00/htmls01.h new file mode 100644 index 000000000..0fd54258b --- /dev/null +++ b/wled00/htmls01.h @@ -0,0 +1,210 @@ +/* + * Settings html + */ +const char PAGE_settings[] PROGMEM = R"=====( + + + + + Settings + + + + +

WLED Settings

+
+ + +

WiFi setup

+

Connect to existing network

+ Network SSID (leave empty to not connect):

+ Network password:

+ Static IP (leave at 0.0.0.0 for DHCP):
+ . + . + . +
+ Static gateway:
+ . + . + . +
+ Static subnet mask:
+ . + . + . +
+ mDNS address (leave empty for no mDNS):
+ http:// .local
+ Client IP: Not connected
+

Configure Access Point

+ AP SSID (leave empty for no AP):

+ Hide AP SSID:
+ AP password (leave empty for open):

+ AP channel:
+ AP IP: Not active
+ +

Application setup

+

Web setup

+ Server description:
+

LED setup

+ Default RGB color: + + +
+ Default brightness: (0-255)
+ Default effect ID:
+ Default effect speed:
+ Ignore and use current color, brightness and effects:
+ Use Gamma correction for brightness:
+ Use Gamma correction for color:
+ Brightness factor: %
+

Button setup

+ On/Off button enabled:
+

Transitions

+ Fade:
+ Transition Delay: ms
+

Timed light

+ Target brightness: (0-255)
+ Change after: min
+ Fade:
+

Daisy chain

+ UDP Port:
+ Receive notifications:
+ Send notifications on direct change:
+ Send notifications on button press:
+ Send nightlight notifications:
+

Time

+ Warning! Using NTP usually results in a complete system crash after 1-48 hours.
+ Please only enable it if you are willing to experiment with it.

+ Get time from NTP server:
+ Current local time is unknown
+

Security

+ OTA locked:
+ Passphrase:
+ To enable OTA, for security reasons you need to also enter the correct password!
+ The password may/should be changed when OTA is enabled.
+ Disable OTA when not in use, otherwise an attacker could reflash device software!

+ Disable recovery AP (Not implemented):
+ In case of a connection error there will be no wireless recovery possible!
+ Completely disables all Access Point functions.

+ Factory reset:
+ All EEPROM content (settings) will be erased.

+ + HTTP traffic is not encrypted. An attacker in the same network could intercept form data!
+

About

+ WLED version 0.3pd
+ (c) 2016-2017 Christian Schwinne
+ Licensed under the MIT license
+ Uses libraries:
+ ESP8266 Arduino Core
+ WS2812FX by kitesurfer1404 (Aircoookie fork)
+ Timezone library by JChristensen
+ Server message: XML response error! +

+ + +
+ + +)====="; +/* + * Settings set html + */ +const char PAGE_settingssaved[] PROGMEM = R"=====( + + + + Saved Settings + + +
+

Settings saved.

+

If you made changes to WiFi configuration, please reboot.


+ + +
+ +)====="; diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 28f20986a..32909ef13 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -15,6 +15,8 @@ #include #include #include +#include "htmls00.h" +#include "htmls01.h" //to toggle usb serial debug (un)comment following line //#define DEBUG diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 313eb6cbc..fe2430171 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -70,7 +70,7 @@ void wledInit() //SERVER INIT //settings page server.on("/settings", HTTP_GET, [](){ - if(!handleFileRead("/settings.htm")) server.send(404, "text/plain", "FileNotFound"); + if(!handleFileRead("/settings.htm")) server.send(200, "text/html", PAGE_settings); }); server.on("/button.png", HTTP_GET, [](){ if(!handleFileRead("/button.png")) server.send(404, "text/plain", "FileNotFound"); @@ -82,7 +82,7 @@ void wledInit() if(!handleFileRead("/favicon.ico")) server.send(404, "text/plain", "FileNotFound"); }); server.on("/", HTTP_GET, [](){ - if(!handleFileRead("/index.htm")) server.send(404, "text/plain", "FileNotFound"); + if(!handleFileRead("/index.htm")) server.send(200, "text/html", PAGE_index); }); server.on("/reset", HTTP_GET, [](){ server.send(200, "text/plain", "Rebooting... Go to main page when lights turn on."); @@ -90,11 +90,11 @@ void wledInit() }); server.on("/set-settings", HTTP_POST, [](){ handleSettingsSet(); - if(!handleFileRead("/settingssaved.htm")) server.send(404, "text/plain", "SettingsSaved"); + if(!handleFileRead("/settingssaved.htm")) server.send(200, "text/html", PAGE_settingssaved); }); if (!ota_lock){ server.on("/edit", HTTP_GET, [](){ - if(!handleFileRead("/edit.htm")) server.send(404, "text/plain", "FileNotFound"); + if(!handleFileRead("/edit.htm")) server.send(200, "text/html", PAGE_edit); }); server.on("/edit", HTTP_PUT, handleFileCreate); server.on("/edit", HTTP_DELETE, handleFileDelete);