mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
Merge remote-tracking branch 'refs/remotes/tzapu/master'
This commit is contained in:
@@ -27,6 +27,8 @@ script:
|
||||
# - arduino -v --verbose-build --verify $PWD/examples/AutoConnect/AutoConnect.ino
|
||||
# - arduino --verify --board arduino:avr:uno $PWD/examples/IncomingCall/IncomingCall.ino
|
||||
# - arduino --verify --board arduino:avr:uno $PWD/examples/AdafruitIO_GPS/AdafruitIO_GPS.ino
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
|
||||
@@ -52,7 +52,7 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are
|
||||
- ~~add to Arduino Library Manager~~
|
||||
- ~~add to PlatformIO~~
|
||||
- add multiple sets of network credentials
|
||||
- allow users to customize CSS
|
||||
- ~~allow users to customize CSS~~
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -179,7 +179,7 @@ void loop() {
|
||||
```
|
||||
See example for a more complex version. [OnDemandConfigPortal](https://github.com/tzapu/WiFiManager/tree/master/examples/OnDemandConfigPortal)
|
||||
|
||||
### Custom Parameters
|
||||
#### Custom Parameters
|
||||
You can use WiFiManager to collect more parameters than just SSID and password.
|
||||
This could be helpful for configuring stuff like MQTT host and port, [blynk](http://www.blynk.cc) or [emoncms](http://emoncms.org) tokens, just to name a few.
|
||||
**You are responsible for saving and loading these custom values.** The library just collects and displays the data for you as a convenience.
|
||||
@@ -198,32 +198,63 @@ Usage scenario would be:
|
||||
```cpp
|
||||
mqtt_server = custom_mqtt_server.getValue();
|
||||
```
|
||||
This feature is a lot more involved than all the others, so here are some examples to fully show how it is done
|
||||
This feature is a lot more involved than all the others, so here are some examples to fully show how it is done.
|
||||
You should also take a look at adding custom HTML to your form.
|
||||
|
||||
- Save and load custom parameters to file system in json form [AutoConnectWithFSParameters](https://github.com/tzapu/WiFiManager/tree/master/examples/AutoConnectWithFSParameters)
|
||||
- *Save and load custom parameters to EEPROM* (not done yet)
|
||||
|
||||
#### Custom IP Configuration
|
||||
You can set a custom IP for both AP (access point, config mode) and STA (station mode, client mode, normal project state)
|
||||
|
||||
### Custom Access Point IP Configuration
|
||||
##### Custom Access Point IP Configuration
|
||||
This will set your captive portal to a specific IP should you need/want such a feature. Add the following snippet before `autoConnect()`
|
||||
```cpp
|
||||
//set custom ip for portal
|
||||
wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
```
|
||||
|
||||
### Custom Station (client) Static IP Configuration
|
||||
##### Custom Station (client) Static IP Configuration
|
||||
This will make use the specified IP configuration instead of using DHCP in station mode.
|
||||
```cpp
|
||||
wifiManager.setSTAStaticIPConfig(IPAddress(192,168,0,99), IPAddress(192,168,0,1), IPAddress(255,255,255,0));
|
||||
```
|
||||
There are a couple of examples in the examples folder that show you how to set a static IP and even how to configure it through the web configuration portal.
|
||||
|
||||
#### Custom HTML, CSS, Javascript
|
||||
There are various ways in which you can inject custom HTML, CSS or Javascript into the configuration portal.
|
||||
The options are:
|
||||
- inject custom head element
|
||||
You can use this to any html bit to the head of the configuration portal. If you add a `<style>` element, bare in mind it overwrites the included css, not replaces.
|
||||
```cpp
|
||||
wifiManager.setCustomHeadElement("<style>html{filter: invert(100%); -webkit-filter: invert(100%);}</style>");
|
||||
```
|
||||
- inject a custom bit of html in the configuration form
|
||||
```cpp
|
||||
WiFiManagerParameter custom_text("<p>This is just a text paragraph</p>");
|
||||
wifiManager.addParameter(&custom_text);
|
||||
```
|
||||
- inject a custom bit of html in a configuration form element
|
||||
Just add the bit you want added as the last parameter to the custom parameter constructor.
|
||||
```cpp
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "iot.eclipse", 40, " readonly");
|
||||
```
|
||||
|
||||
#### Filter Networks
|
||||
If you would like to filter low signal quality networks you can tell WiFiManager to not show networks below an arbitrary quality %;
|
||||
You can filter networks based on signal quality and show/hide duplicate networks.
|
||||
|
||||
- If you would like to filter low signal quality networks you can tell WiFiManager to not show networks below an arbitrary quality %;
|
||||
```cpp
|
||||
wifiManager.setMinimumSignalQuality(10);
|
||||
```
|
||||
will not show networks under 10% signal quality. If you omit the parameter it defaults to 8%;
|
||||
|
||||
- You can also remove or show duplicate networks (default is remove).
|
||||
Use this function to show (or hide) all networks.
|
||||
```cpp
|
||||
wifiManager.setRemoveDuplicateAPs(false);
|
||||
```
|
||||
|
||||
#### Debug
|
||||
Debug is enabled by default on Serial. To disable add before autoConnect
|
||||
```cpp
|
||||
@@ -242,7 +273,19 @@ If you connect to the created configuration Access Point but the configuration p
|
||||
If trying to connect ends up in an endless loop, try to add `setConnectTimeout(60)` before `autoConnect();`. The parameter is timeout to try connecting in seconds.
|
||||
|
||||
## Releases
|
||||
#### 0.10
|
||||
#### 0.12
|
||||
- removed 204 header response
|
||||
- fixed incompatibility with other libs using isnan and other std:: functions without namespace
|
||||
|
||||
##### 0.11
|
||||
- a lot more reliable reconnecting to networks
|
||||
- custom html in custom parameters (for read only params)
|
||||
- custom html in custom parameter form (like labels)
|
||||
- custom head element (like custom css)
|
||||
- sort networks based on signal quality
|
||||
- remove duplicate networks
|
||||
|
||||
##### 0.10
|
||||
- some css changes
|
||||
- bug fixes and speed improvements
|
||||
- added an alternative to waitForConnectResult() for debugging
|
||||
|
||||
+32
-22
@@ -64,6 +64,14 @@ WiFiManager::WiFiManager() {
|
||||
}
|
||||
|
||||
void WiFiManager::addParameter(WiFiManagerParameter *p) {
|
||||
if(_paramsCount + 1 > WIFI_MANAGER_MAX_PARAMS)
|
||||
{
|
||||
//Max parameters exceeded!
|
||||
DEBUG_WM("WIFI_MANAGER_MAX_PARAMS exceeded, increase number (in WiFiManager.h) before adding more parameters!");
|
||||
DEBUG_WM("Skipping parameter with ID:");
|
||||
DEBUG_WM(p->getID());
|
||||
return;
|
||||
}
|
||||
_params[_paramsCount] = p;
|
||||
_paramsCount++;
|
||||
DEBUG_WM("Adding parameter");
|
||||
@@ -115,7 +123,7 @@ void WiFiManager::setupConfigPortal() {
|
||||
server->on("/wifisave", std::bind(&WiFiManager::handleWifiSave, this));
|
||||
server->on("/i", std::bind(&WiFiManager::handleInfo, this));
|
||||
server->on("/r", std::bind(&WiFiManager::handleReset, this));
|
||||
server->on("/generate_204", std::bind(&WiFiManager::handle204, this)); //Android/Chrome OS captive portal check.
|
||||
//server->on("/generate_204", std::bind(&WiFiManager::handle204, this)); //Android/Chrome OS captive portal check.
|
||||
server->on("/fwlink", std::bind(&WiFiManager::handleRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
|
||||
server->onNotFound (std::bind(&WiFiManager::handleNotFound, this));
|
||||
server->begin(); // Web server start
|
||||
@@ -149,6 +157,11 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
return startConfigPortal(apName, apPassword);
|
||||
}
|
||||
|
||||
boolean WiFiManager::startConfigPortal() {
|
||||
String ssid = "ESP" + String(ESP.getChipId());
|
||||
return startConfigPortal(ssid.c_str(), NULL);
|
||||
}
|
||||
|
||||
boolean WiFiManager::startConfigPortal(char const *apName, char const *apPassword) {
|
||||
//setup AP
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
@@ -229,7 +242,7 @@ int WiFiManager::connectWifi(String ssid, String pass) {
|
||||
if (ssid != "") {
|
||||
WiFi.begin(ssid.c_str(), pass.c_str());
|
||||
} else {
|
||||
if(WiFi.SSID()) {
|
||||
if (WiFi.SSID()) {
|
||||
DEBUG_WM("Using last saved values, should be faster");
|
||||
//trying to fix connection in progress hanging
|
||||
ETS_UART_INTR_DISABLE();
|
||||
@@ -400,30 +413,27 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
// RSSI SORT
|
||||
|
||||
// old sort
|
||||
// for (int i = 0; i < n; i++) {
|
||||
// for (int j = i + 1; j < n; j++) {
|
||||
// if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
|
||||
// //int temp = indices[j];
|
||||
// //indices[j] = indices[i];
|
||||
// //indices[i] = temp;
|
||||
// std::swap(indices[i], indices[j]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = i + 1; j < n; j++) {
|
||||
if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
|
||||
std::swap(indices[i], indices[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(indices, indices + n, [](const int & a, const int & b) -> bool
|
||||
{
|
||||
/*std::sort(indices, indices + n, [](const int & a, const int & b) -> bool
|
||||
{
|
||||
return WiFi.RSSI(a) > WiFi.RSSI(b);
|
||||
});
|
||||
});*/
|
||||
|
||||
// remove duplicates ( must be RSSI sorted )
|
||||
if(_removeDuplicateAPs){
|
||||
if (_removeDuplicateAPs) {
|
||||
String cssid;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if(indices[i] == -1) continue;
|
||||
if (indices[i] == -1) continue;
|
||||
cssid = WiFi.SSID(indices[i]);
|
||||
for (int j = i + 1; j < n; j++) {
|
||||
if(cssid == WiFi.SSID(indices[j])){
|
||||
if (cssid == WiFi.SSID(indices[j])) {
|
||||
DEBUG_WM("DUP AP: " + WiFi.SSID(indices[j]));
|
||||
indices[j] = -1; // set dup aps to index -1
|
||||
}
|
||||
@@ -433,7 +443,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
|
||||
//display networks in page
|
||||
for (int i = 0; i < n; i++) {
|
||||
if(indices[i] == -1) continue; // skip dups
|
||||
if (indices[i] == -1) continue; // skip dups
|
||||
DEBUG_WM(WiFi.SSID(indices[i]));
|
||||
DEBUG_WM(WiFi.RSSI(indices[i]));
|
||||
int quality = getRSSIasQuality(WiFi.RSSI(indices[i]));
|
||||
@@ -651,14 +661,14 @@ void WiFiManager::handleReset() {
|
||||
|
||||
|
||||
|
||||
|
||||
void WiFiManager::handle204() {
|
||||
//removed as mentioned here https://github.com/tzapu/WiFiManager/issues/114
|
||||
/*void WiFiManager::handle204() {
|
||||
DEBUG_WM(F("204 No Response"));
|
||||
server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
server->sendHeader("Pragma", "no-cache");
|
||||
server->sendHeader("Expires", "-1");
|
||||
server->send ( 204, "text/plain", "");
|
||||
}
|
||||
}*/
|
||||
|
||||
void WiFiManager::handleNotFound() {
|
||||
if (captivePortal()) { // If captive portal redirect instead of displaying the error page.
|
||||
|
||||
+2
-5
@@ -17,21 +17,17 @@
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <DNSServer.h>
|
||||
#include <memory>
|
||||
#undef min
|
||||
#undef max
|
||||
#include <algorithm>
|
||||
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
|
||||
const char HTTP_200[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
|
||||
const char HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>";
|
||||
const char HTTP_STYLE[] PROGMEM = "<style>.c{text-align: center;} div,input{padding:5px;font-size:1em;} input{width:95%;} body{text-align: center;font-family:verdana;} button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;} .q{float: right;width: 64px;text-align: right;} .l{background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==\") no-repeat left center;background-size: 1em;}</style>";
|
||||
const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
||||
const char HTTP_HEAD_END[] PROGMEM = "</head><body><div style='text-align:left;display:inline-block;min-width:260px;'>";
|
||||
const char HTTP_PORTAL_OPTIONS[] PROGMEM = "<form action=\"/wifi\" method=\"get\"><button>Configure WiFi</button></form><br/><form action=\"/0wifi\" method=\"get\"><button>Configure WiFi (No Scan)</button></form><br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/><form action=\"/r\" method=\"post\"><button>Reset</button></form>";
|
||||
const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {i}'>{r}%</span></div>";
|
||||
//const char HTTP_ITEM_PADLOCK[] PROGMEM = "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==' width='13px'/>";
|
||||
const char HTTP_FORM_START[] PROGMEM = "<form method='get' action='wifisave'><input id='s' name='s' length=32 placeholder='SSID'><br/><input id='p' name='p' length=64 type='password' placeholder='password'><br/>";
|
||||
const char HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' length={l} placeholder='{p}' value='{v}' {c}>";
|
||||
const char HTTP_FORM_END[] PROGMEM = "<br/><button type='submit'>save</button></form>";
|
||||
@@ -74,6 +70,7 @@ class WiFiManager
|
||||
boolean autoConnect(char const *apName, char const *apPassword = NULL);
|
||||
|
||||
//if you want to always start the config portal, without trying to connect first
|
||||
boolean startConfigPortal();
|
||||
boolean startConfigPortal(char const *apName, char const *apPassword = NULL);
|
||||
|
||||
// get the AP name of the config portal, so it can be used in the callback
|
||||
|
||||
@@ -17,7 +17,7 @@ void setup() {
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//set custom ip for portal
|
||||
//wifiManager.setAPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
//wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
|
||||
//fetches ssid and pass from eeprom and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
|
||||
@@ -74,7 +74,7 @@ void setup() {
|
||||
// After connecting, parameter.getValue() will get you the configured value
|
||||
// id/name placeholder/prompt default length
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
|
||||
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 5);
|
||||
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 6);
|
||||
WiFiManagerParameter custom_blynk_token("blynk", "blynk token", blynk_token, 32);
|
||||
|
||||
//WiFiManager
|
||||
|
||||
@@ -35,16 +35,21 @@ void setup() {
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//set static ip
|
||||
//the commented bit only works for ESP8266 core 2.1.0 or newer
|
||||
/*IPAddress _ip,_gw,_sn;
|
||||
_ip.fromString(static_ip);
|
||||
_gw.fromString(static_gw);
|
||||
_sn.fromString(static_sn);
|
||||
*/
|
||||
//set static ip
|
||||
//block1 should be used for ESP8266 core 2.1.0 or newer, otherwise use block2
|
||||
|
||||
//start-block1
|
||||
//IPAddress _ip,_gw,_sn;
|
||||
//_ip.fromString(static_ip);
|
||||
//_gw.fromString(static_gw);
|
||||
//_sn.fromString(static_sn);
|
||||
//end-block1
|
||||
|
||||
//start-block2
|
||||
IPAddress _ip = IPAddress(10, 0, 1, 78);
|
||||
IPAddress _gw = IPAddress(10, 0, 1, 1);
|
||||
IPAddress _sn = IPAddress(255, 255, 255, 0);
|
||||
//end-block2
|
||||
|
||||
wifiManager.setSTAStaticIPConfig(_ip, _gw, _sn);
|
||||
|
||||
|
||||
@@ -1,38 +1,80 @@
|
||||
<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>
|
||||
<style>.c{text-align: center;} div,input{padding:5px;font-size:1em;} input{width:95%;} body{text-align: center;font-family:verdana;} button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;} .q{float: right;width: 64px;text-align: right;} .l{background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==") no-repeat left center;background-size: 1em;}</style>
|
||||
<!-- HTTP_HEAD -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>
|
||||
<title>{v}</title>
|
||||
<!-- /HTTP_HEAD -->
|
||||
<!-- HTTP_STYLE -->
|
||||
<style>
|
||||
.c{text-align: center;}
|
||||
div,input{padding:5px;font-size:1em;}
|
||||
input{width:95%;}
|
||||
body{text-align: center;font-family:verdana;}
|
||||
button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;}
|
||||
.q{float: right;width: 64px;text-align: right;}
|
||||
.l{background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==") no-repeat left center;background-size: 1em;}
|
||||
</style>
|
||||
<!-- /HTTP_STYLE -->
|
||||
<!-- HTTP_SCRIPT -->
|
||||
<script>
|
||||
function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}
|
||||
</script>
|
||||
<!-- /HTTP_SCRIPT -->
|
||||
<!-- HTTP_HEAD_END -->
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align:left;display:inline-block;min-width:260px;">
|
||||
<!-- /HTTP_HEAD_END -->
|
||||
|
||||
<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>
|
||||
</head><body><div style="text-align:left;display:inline-block;min-width:260px;">
|
||||
<!--
|
||||
<div><a href='#' onclick='c(this)'>{v}</a> {r}% {i}</div>
|
||||
<div><a href='#' onclick='c(this)'>{v}</a> 100% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAKCAMAAAC+Ge+yAAAACVBMVEUAAAC7u7v///9etNz6AAAAI0lEQVQI133GsQ3AMAAEoXv2H9qNJacKFbEaWTQJ+uQB/nMdEaYAXeJkZ9AAAAAASUVORK5CYII='/></div>
|
||||
<div><a href='#' onclick='c(this)'>Vila17</a> 95% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAADFBMVEUAAAAAtgD///8AAADV1YIHAAAAA3RSTlMAAAD6dsTeAAAAHUlEQVR4AWMAAmYgYGBkArHAAMoEYnQmMxSQywQAKvMA3+mlSFAAAAAASUVORK5CYII='/></div>
|
||||
<div><a href='#'>LilRid</a> 100% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAABlBMVEUAAAD///+l2Z/dAAAAIklEQVR4AWNgZGRkAAIQBURQDEZAgM5kgAJGEAQDwkxkbQAOhgBBk64+mQAAAABJRU5ErkJggg=='/></div>
|
||||
<div><a href='#'>Marcelica</a> 100% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAACVBMVEUAAAC7u7v///9etNz6AAAAJ0lEQVR4AY3GsREAIBSDUD77D63x4tlKw0MdmD0ijTO9f6SFnv7YXB4qAIVn0xoMAAAAAElFTkSuQmCC'/></div>
|
||||
<div><a href='#'>PMica</a> 110% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==' width="13px"/></div>
|
||||
-->
|
||||
|
||||
<style>
|
||||
.q{float: right;width: 64px;text-align: right;}
|
||||
.l{background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==") no-repeat left center;background-size: 1em;}
|
||||
</style>
|
||||
<!--
|
||||
<div><a href='#' onclick='c(this)'>{v}</a> {r}% {i}</div>
|
||||
<div><a href='#' onclick='c(this)'>{v}</a> 100% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAKCAMAAAC+Ge+yAAAACVBMVEUAAAC7u7v///9etNz6AAAAI0lEQVQI133GsQ3AMAAEoXv2H9qNJacKFbEaWTQJ+uQB/nMdEaYAXeJkZ9AAAAAASUVORK5CYII='/></div>
|
||||
<div><a href='#' onclick='c(this)'>Vila17</a> 95% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAADFBMVEUAAAAAtgD///8AAADV1YIHAAAAA3RSTlMAAAD6dsTeAAAAHUlEQVR4AWMAAmYgYGBkArHAAMoEYnQmMxSQywQAKvMA3+mlSFAAAAAASUVORK5CYII='/></div>
|
||||
<div><a href='#'>LilRid</a> 100% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAABlBMVEUAAAD///+l2Z/dAAAAIklEQVR4AWNgZGRkAAIQBURQDEZAgM5kgAJGEAQDwkxkbQAOhgBBk64+mQAAAABJRU5ErkJggg=='/></div>
|
||||
<div><a href='#'>Marcelica</a> 100% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAACVBMVEUAAAC7u7v///9etNz6AAAAJ0lEQVR4AY3GsREAIBSDUD77D63x4tlKw0MdmD0ijTO9f6SFnv7YXB4qAIVn0xoMAAAAAElFTkSuQmCC'/></div>
|
||||
<div><a href='#'>PMica</a> 110% <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==' width="13px"/></div>
|
||||
-->
|
||||
|
||||
<div><a href='#' onclick='c(this)'>{v}</a> <span class="q {i}">{r}%</span></div>
|
||||
<div><a href='#'>PMisa</a> <span class="q l">100%</span> </div>
|
||||
<div><a href='#'>Dragos_Networks</a> <span class="q l">10%</span> </div>
|
||||
<div><a href='#'>PMisa</a> <span class="q l">8%</span> </div>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
<form method='get' action='wifisave'><input id='s' name='s' length=32 placeholder='SSID'><br/><input id='p' name='p' length=64 placeholder='password'><br/><button type='submit'>save</button></form>
|
||||
<br/><div></div>
|
||||
<br/>
|
||||
<form action=\"/wifi\" method=\"get\"><button>Configure WiFi</button></form><br/>
|
||||
<form action=\"/0wifi\" method=\"get\"><button>Configure WiFi (No Scan)</button></form>
|
||||
<br>
|
||||
<div class="c"><a href=\"/wifi\">Scan</a></div>
|
||||
<!--style>
|
||||
.q{float: right;width: 64px;text-align: right;}
|
||||
.l{background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==") no-repeat left center;background-size: 1em;}
|
||||
</style-->
|
||||
|
||||
|
||||
<!-- HTTP_PORTAL_OPTIONS -->
|
||||
<form action=\"/wifi\" method=\"get\"><button>Configure WiFi</button></form><br/><form action=\"/0wifi\" method=\"get\"><button>Configure WiFi (No Scan)</button></form><br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/><form action=\"/r\" method=\"post\"><button>Reset</button></form>
|
||||
<!-- /HTTP_PORTAL_OPTIONS -->
|
||||
|
||||
<div><a href='#' onclick='c(this)'>{v}</a> <span class="q {i}">{r}%</span></div>
|
||||
<div><a href='#'>PMisa</a> <span class="q l">100%</span> </div>
|
||||
<div><a href='#'>Dragos_Networks</a> <span class="q l">10%</span> </div>
|
||||
<div><a href='#'>PMisa</a> <span class="q l">8%</span> </div>
|
||||
|
||||
<!-- HTTP_ITEM -->
|
||||
<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {i}'>{r}%</span></div>
|
||||
<!-- /HTTP_ITEM -->
|
||||
<!-- HTTP_FORM_START -->
|
||||
<form method='get' action='wifisave'><input id='s' name='s' length=32 placeholder='SSID'><br/><input id='p' name='p' length=64 type='password' placeholder='password'><br/>
|
||||
<!-- /HTTP_FORM_START -->
|
||||
<!-- HTTP_FORM_PARAM -->
|
||||
<br/><input id='{i}' name='{n}' length='{l}' placeholder='{p}' value='{v}' {c}>
|
||||
<!-- /HTTP_FORM_PARAM -->
|
||||
<!-- HTTP_FORM_END -->
|
||||
<br/><button type='submit'>save</button></form>
|
||||
<!-- /HTTP_FORM_END -->
|
||||
<!-- HTTP_SCAN_LINK -->
|
||||
<br/><div class=\"c\"><a href=\"/wifi\">Scan</a></div>
|
||||
<!-- /HTTP_SCAN_LINK -->
|
||||
<!-- HTTP_SAVED -->
|
||||
<div>Credentials Saved<br />Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>
|
||||
<!-- /HTTP_SAVED -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- HTTP_END -->
|
||||
</div>
|
||||
</body></html>
|
||||
</body>
|
||||
</html>
|
||||
<!-- /HTTP_END -->
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
console.log('starting');
|
||||
|
||||
const inFile = 'WiFiManager.template.html';
|
||||
const outFile = 'template.h';
|
||||
|
||||
const defineRegEx = /<!-- ([A-Z_]+) -->/gm;
|
||||
console.log('parsing', inFile);
|
||||
|
||||
fs.readFile(inFile, 'utf8', function (err,data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
//console.log(data);
|
||||
|
||||
let defines = data.match(defineRegEx);
|
||||
|
||||
//console.log(defines);
|
||||
var stream = fs.createWriteStream(outFile);
|
||||
stream.once('open', function(fd) {
|
||||
for (const i in defines) {
|
||||
|
||||
const start = defines[i];
|
||||
const end = start.replace('<!-- ', '<!-- /')
|
||||
defineRegEx.lastIndex = 0;
|
||||
const constantName = defineRegEx.exec(start)[1];
|
||||
|
||||
console.log(constantName);
|
||||
var extractRE = new RegExp(start + '([\\s\\S]+)' + end, 'gm');
|
||||
let extractArray = extractRE.exec(data);
|
||||
if(extractArray.length > 1) {
|
||||
let def = extractArray[1];
|
||||
//console.log(def);
|
||||
//minimise a bit
|
||||
def = def.replace(/\s+/g, ' ');
|
||||
def = def.replace(/>\s+</g, '><');
|
||||
def = def.trim();
|
||||
//more extraneous spaces - possible bad results, needs to be checked
|
||||
//def = def.replace(/(\w)\s(\W)|(\W)\s(\w)|(\W)\s(\W)/g, '$1$2$3$4$5$6');
|
||||
def = def.replace(/(\w)\s(\W)|(\W)\s(\w)/g, '$1$2$3$4');
|
||||
//escape double quotes
|
||||
def = def.replace(/\\([\s\S])|(")/g, "\\$1$2");
|
||||
|
||||
|
||||
console.log(def);
|
||||
//const char HTTP_HEAD[] PROGMEM =
|
||||
let string = 'const char ' + constantName + '[] PROGMEM';
|
||||
for (let i = string.length; i < 42; i++) {
|
||||
string += ' ';
|
||||
}
|
||||
string += '= "' + def + '";\n';
|
||||
stream.write(string);
|
||||
}
|
||||
}
|
||||
stream.end();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
const char HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\"content=\"width=device-width,initial-scale=1,user-scalable=no\"/><title>{v}</title>";
|
||||
const char HTTP_STYLE[] PROGMEM = "<style> .c{text-align:center;}div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align:center;font-family:verdana;}button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;} .q{float:right;width:64px;text-align:right;} .l{background:url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==\")no-repeat left center;background-size:1em;} </style>";
|
||||
const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();} </script>";
|
||||
const char HTTP_HEAD_END[] PROGMEM = "</head><body><div style=\"text-align:left;display:inline-block;min-width:260px;\">";
|
||||
const char HTTP_PORTAL_OPTIONS[] PROGMEM = "<form action=\"/wifi\"method=\"get\"><button>Configure WiFi</button></form><br/><form action=\"/0wifi\"method=\"get\"><button>Configure WiFi(No Scan)</button></form><br/><form action=\"/i\"method=\"get\"><button>Info</button></form><br/><form action=\"/r\"method=\"post\"><button>Reset</button></form>";
|
||||
const char HTTP_ITEM[] PROGMEM = "<div><a href='#p'onclick='c(this)'>{v}</a> <span class='q{i}'>{r}%</span></div>";
|
||||
const char HTTP_FORM_START[] PROGMEM = "<form method='get'action='wifisave'><input id='s'name='s'length=32 placeholder='SSID'><br/><input id='p'name='p'length=64 type='password'placeholder='password'><br/>";
|
||||
const char HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}'name='{n}'length={l}placeholder='{p}'value='{v}' {c}>";
|
||||
const char HTTP_FORM_END[] PROGMEM = "<br/><button type='submit'>save</button></form>";
|
||||
const char HTTP_SCAN_LINK[] PROGMEM = "<br/><div class=\"c\"><a href=\"/wifi\">Scan</a></div>";
|
||||
const char HTTP_SAVED[] PROGMEM = "<div>Credentials Saved<br/>Trying to connect ESP to network.<br/>If it fails reconnect to AP to try again</div>";
|
||||
const char HTTP_END[] PROGMEM = "</div></body></html>";
|
||||
+2
-2
@@ -8,6 +8,6 @@
|
||||
"url": "https://github.com/tzapu/WiFiManager.git"
|
||||
},
|
||||
"frameworks": "arduino",
|
||||
"platforms": "espressif",
|
||||
"version": "0.10"
|
||||
"platforms": "espressif8266",
|
||||
"version": "0.12"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=WiFiManager
|
||||
version=0.10
|
||||
version=0.12
|
||||
author=tzapu
|
||||
maintainer=tzapu
|
||||
sentence=ESP8266 WiFi Connection manager with fallback web configuration portal
|
||||
|
||||
Reference in New Issue
Block a user