mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-15 07:31:21 +10:00
Merge branch 'master' into resetConfigCallback
This commit is contained in:
@@ -43,16 +43,19 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are
|
||||
 
|
||||
|
||||
## Wishlist
|
||||
- ~~remove dependency on EEPROM library~~
|
||||
- ~~move HTML Strings to PROGMEM~~
|
||||
- ~~cleanup and streamline code~~ (although this is ongoing)
|
||||
- if timeout is set, extend it when a page is fetched in AP mode
|
||||
- ~~add ability to configure more parameters than ssid/password~~
|
||||
- ~~maybe allow setting ip of ESP after reboot~~
|
||||
- ~~add to Arduino Library Manager~~
|
||||
- ~~add to PlatformIO~~
|
||||
- add multiple sets of network credentials
|
||||
- ~~allow users to customize CSS~~
|
||||
- [x] remove dependency on EEPROM library
|
||||
- [x] move HTML Strings to PROGMEM
|
||||
- [x] cleanup and streamline code (although this is ongoing)
|
||||
- [x] if timeout is set, extend it when a page is fetched in AP mode
|
||||
- [x] add ability to configure more parameters than ssid/password
|
||||
- [x] maybe allow setting ip of ESP after reboot
|
||||
- [x] add to Arduino Library Manager
|
||||
- [x] add to PlatformIO
|
||||
- [ ] add multiple sets of network credentials
|
||||
- [x] allow users to customize CSS
|
||||
- [ ] ESP32 support or instructions
|
||||
- [ ] rewrite documentation for simplicity, based on scenarios/goals
|
||||
- [ ] rely on the SDK's built in auto connect more than forcing a connect
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
||||
+9
-13
@@ -396,6 +396,7 @@ void WiFiManager::handleRoot() {
|
||||
page += FPSTR(HTTP_PORTAL_OPTIONS);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
server->sendHeader("Content-Length", String(page.length()));
|
||||
server->send(200, "text/html", page);
|
||||
|
||||
}
|
||||
@@ -486,7 +487,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
}
|
||||
|
||||
page += FPSTR(HTTP_FORM_START);
|
||||
char parLength[2];
|
||||
char parLength[5];
|
||||
// add the extra parameters to the form
|
||||
for (int i = 0; i < _paramsCount; i++) {
|
||||
if (_params[i] == NULL) {
|
||||
@@ -498,7 +499,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
pitem.replace("{i}", _params[i]->getID());
|
||||
pitem.replace("{n}", _params[i]->getID());
|
||||
pitem.replace("{p}", _params[i]->getPlaceholder());
|
||||
snprintf(parLength, 2, "%d", _params[i]->getValueLength());
|
||||
snprintf(parLength, 5, "%d", _params[i]->getValueLength());
|
||||
pitem.replace("{l}", parLength);
|
||||
pitem.replace("{v}", _params[i]->getValue());
|
||||
pitem.replace("{c}", _params[i]->getCustomHTML());
|
||||
@@ -549,6 +550,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
server->sendHeader("Content-Length", String(page.length()));
|
||||
server->send(200, "text/html", page);
|
||||
|
||||
|
||||
@@ -606,6 +608,7 @@ void WiFiManager::handleWifiSave() {
|
||||
page += FPSTR(HTTP_SAVED);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
server->sendHeader("Content-Length", String(page.length()));
|
||||
server->send(200, "text/html", page);
|
||||
|
||||
DEBUG_WM(F("Sent wifi save page"));
|
||||
@@ -648,6 +651,7 @@ void WiFiManager::handleInfo() {
|
||||
page += F("</dl>");
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
server->sendHeader("Content-Length", String(page.length()));
|
||||
server->send(200, "text/html", page);
|
||||
|
||||
DEBUG_WM(F("Sent info page"));
|
||||
@@ -665,6 +669,8 @@ void WiFiManager::handleReset() {
|
||||
page += FPSTR(HTTP_HEAD_END);
|
||||
page += F("Module will reset in a few seconds.");
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
server->sendHeader("Content-Length", String(page.length()));
|
||||
server->send(200, "text/html", page);
|
||||
|
||||
DEBUG_WM(F("Sent reset page"));
|
||||
@@ -673,17 +679,6 @@ void WiFiManager::handleReset() {
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//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.
|
||||
return;
|
||||
@@ -703,6 +698,7 @@ void WiFiManager::handleNotFound() {
|
||||
server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
server->sendHeader("Pragma", "no-cache");
|
||||
server->sendHeader("Expires", "-1");
|
||||
server->sendHeader("Content-Length", String(message.length()));
|
||||
server->send ( 404, "text/plain", message );
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ const char HTTP_HEAD_END[] PROGMEM = "</head><body><div style='text-align
|
||||
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_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' maxlength={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>";
|
||||
@@ -79,12 +79,12 @@ class WiFiManager
|
||||
void resetSettings();
|
||||
|
||||
//sets timeout before webserver loop ends and exits even if there has been no setup.
|
||||
//usefully for devices that failed to connect at some point and got stuck in a webserver loop
|
||||
//useful for devices that failed to connect at some point and got stuck in a webserver loop
|
||||
//in seconds setConfigPortalTimeout is a new name for setTimeout
|
||||
void setConfigPortalTimeout(unsigned long seconds);
|
||||
void setTimeout(unsigned long seconds);
|
||||
|
||||
//sets timeout for which to attempt connecting, usefull if you get a lot of failed connects
|
||||
//sets timeout for which to attempt connecting, useful if you get a lot of failed connects
|
||||
void setConnectTimeout(unsigned long seconds);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class WiFiManager
|
||||
void setConfigResetCallback(void(*func)(void));
|
||||
//adds a custom parameter
|
||||
void addParameter(WiFiManagerParameter *p);
|
||||
//if this is set, it will exit after config, even if connection is unsucessful.
|
||||
//if this is set, it will exit after config, even if connection is unsuccessful.
|
||||
void setBreakAfterConfig(boolean shouldBreak);
|
||||
//if this is set, try WPS setup when starting (this will delay config portal for up to 2 mins)
|
||||
//TODO
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <DNSServer.h>
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
||||
|
||||
// select wich pin will trigger the configuraton portal when set to LOW
|
||||
// select which pin will trigger the configuration portal when set to LOW
|
||||
// ESP-01 users please note: the only pins available (0 and 2), are shared
|
||||
// with the bootloader, so always set them HIGH at power-up
|
||||
#define TRIGGER_PIN 0
|
||||
|
||||
Reference in New Issue
Block a user