mirror of
https://github.com/gunner47/GyverLamp.git
synced 2025-08-10 18:27:35 +03:00
Обновление библиотек
This commit is contained in:
@@ -143,18 +143,17 @@ void WiFiManager::setupConfigPortal() {
|
||||
dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
|
||||
|
||||
/* Setup web pages: root, wifi config pages, SO captive portal detectors and not found. */
|
||||
server->on(String(F("/")), std::bind(&WiFiManager::handleRoot, this));
|
||||
server->on(String(F("/wifi")), std::bind(&WiFiManager::handleWifi, this, true));
|
||||
server->on(String(F("/0wifi")), std::bind(&WiFiManager::handleWifi, this, false));
|
||||
server->on(String(F("/wifisave")), std::bind(&WiFiManager::handleWifiSave, this));
|
||||
server->on(String(F("/i")), std::bind(&WiFiManager::handleInfo, this));
|
||||
server->on(String(F("/r")), std::bind(&WiFiManager::handleReset, this));
|
||||
server->on(String(F("/")).c_str(), std::bind(&WiFiManager::handleRoot, this));
|
||||
server->on(String(F("/wifi")).c_str(), std::bind(&WiFiManager::handleWifi, this, true));
|
||||
server->on(String(F("/0wifi")).c_str(), std::bind(&WiFiManager::handleWifi, this, false));
|
||||
server->on(String(F("/wifisave")).c_str(), std::bind(&WiFiManager::handleWifiSave, this));
|
||||
server->on(String(F("/i")).c_str(), std::bind(&WiFiManager::handleInfo, this));
|
||||
server->on(String(F("/r")).c_str(), std::bind(&WiFiManager::handleReset, this));
|
||||
//server->on("/generate_204", std::bind(&WiFiManager::handle204, this)); //Android/Chrome OS captive portal check.
|
||||
server->on(String(F("/fwlink")), std::bind(&WiFiManager::handleRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
|
||||
server->on(String(F("/fwlink")).c_str(), 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
|
||||
DEBUG_WM(F("HTTP server started"));
|
||||
|
||||
}
|
||||
|
||||
boolean WiFiManager::autoConnect() {
|
||||
@@ -283,7 +282,7 @@ int WiFiManager::connectWifi(String ssid, String pass) {
|
||||
DEBUG_WM(WiFi.localIP());
|
||||
}
|
||||
//fix for auto connect racing issue
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
if (WiFi.status() == WL_CONNECTED && (WiFi.SSID() == ssid)) {
|
||||
DEBUG_WM(F("Already connected. Bailing out."));
|
||||
return WL_CONNECTED;
|
||||
}
|
||||
@@ -291,7 +290,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(F("Using last saved values, should be faster"));
|
||||
//trying to fix connection in progress hanging
|
||||
ETS_UART_INTR_DISABLE();
|
||||
@@ -332,7 +331,7 @@ uint8_t WiFiManager::waitForConnectResult() {
|
||||
keepConnecting = false;
|
||||
DEBUG_WM (F("Connection timed out"));
|
||||
}
|
||||
if (status == WL_CONNECTED || status == WL_CONNECT_FAILED) {
|
||||
if (status == WL_CONNECTED) {
|
||||
keepConnecting = false;
|
||||
}
|
||||
delay(100);
|
||||
@@ -420,12 +419,12 @@ void WiFiManager::handleRoot() {
|
||||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
String page = FPSTR(HTTP_HEADER);
|
||||
page.replace("{v}", "Options");
|
||||
page += FPSTR(HTTP_SCRIPT);
|
||||
page += FPSTR(HTTP_STYLE);
|
||||
page += _customHeadElement;
|
||||
page += FPSTR(HTTP_HEAD_END);
|
||||
page += FPSTR(HTTP_HEADER_END);
|
||||
page += String(F("<h1>"));
|
||||
page += _apName;
|
||||
page += String(F("</h1>"));
|
||||
@@ -441,12 +440,12 @@ void WiFiManager::handleRoot() {
|
||||
/** Wifi config page handler */
|
||||
void WiFiManager::handleWifi(boolean scan) {
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
String page = FPSTR(HTTP_HEADER);
|
||||
page.replace("{v}", "Config ESP");
|
||||
page += FPSTR(HTTP_SCRIPT);
|
||||
page += FPSTR(HTTP_STYLE);
|
||||
page += _customHeadElement;
|
||||
page += FPSTR(HTTP_HEAD_END);
|
||||
page += FPSTR(HTTP_HEADER_END);
|
||||
|
||||
if (scan) {
|
||||
int n = WiFi.scanNetworks();
|
||||
@@ -636,12 +635,12 @@ void WiFiManager::handleWifiSave() {
|
||||
optionalIPFromString(&_sta_static_sn, sn.c_str());
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
String page = FPSTR(HTTP_HEADER);
|
||||
page.replace("{v}", "Credentials Saved");
|
||||
page += FPSTR(HTTP_SCRIPT);
|
||||
page += FPSTR(HTTP_STYLE);
|
||||
page += _customHeadElement;
|
||||
page += FPSTR(HTTP_HEAD_END);
|
||||
page += FPSTR(HTTP_HEADER_END);
|
||||
page += FPSTR(HTTP_SAVED);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
@@ -657,12 +656,12 @@ void WiFiManager::handleWifiSave() {
|
||||
void WiFiManager::handleInfo() {
|
||||
DEBUG_WM(F("Info"));
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
String page = FPSTR(HTTP_HEADER);
|
||||
page.replace("{v}", "Info");
|
||||
page += FPSTR(HTTP_SCRIPT);
|
||||
page += FPSTR(HTTP_STYLE);
|
||||
page += _customHeadElement;
|
||||
page += FPSTR(HTTP_HEAD_END);
|
||||
page += FPSTR(HTTP_HEADER_END);
|
||||
page += F("<dl>");
|
||||
page += F("<dt>Chip ID</dt><dd>");
|
||||
page += ESP.getChipId();
|
||||
@@ -698,12 +697,12 @@ void WiFiManager::handleInfo() {
|
||||
void WiFiManager::handleReset() {
|
||||
DEBUG_WM(F("Reset"));
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
String page = FPSTR(HTTP_HEADER);
|
||||
page.replace("{v}", "Info");
|
||||
page += FPSTR(HTTP_SCRIPT);
|
||||
page += FPSTR(HTTP_STYLE);
|
||||
page += _customHeadElement;
|
||||
page += FPSTR(HTTP_HEAD_END);
|
||||
page += FPSTR(HTTP_HEADER_END);
|
||||
page += F("Module will reset in a few seconds.");
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
|
@@ -22,10 +22,10 @@ extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
|
||||
const char HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\" name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>";
|
||||
const char HTTP_HEADER[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><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_HEADER_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/>";
|
||||
@@ -125,7 +125,7 @@ class WiFiManager
|
||||
//const int WM_DONE = 0;
|
||||
//const int WM_WAIT = 10;
|
||||
|
||||
//const String HTTP_HEAD = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/><title>{v}</title>";
|
||||
//const String HTTP_HEADER = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/><title>{v}</title>";
|
||||
|
||||
void setupConfigPortal();
|
||||
void startWPS();
|
||||
|
@@ -9,5 +9,5 @@
|
||||
},
|
||||
"frameworks": "arduino",
|
||||
"platforms": "espressif8266",
|
||||
"version": "0.14"
|
||||
"version": "0.15.0-beta"
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
name=WiFiManager
|
||||
version=0.14
|
||||
version=0.15.0-beta
|
||||
author=tzapu
|
||||
maintainer=tzapu
|
||||
sentence=ESP8266 WiFi Connection manager with fallback web configuration portal
|
||||
|
Reference in New Issue
Block a user