mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-14 15:11:32 +10:00
added some esp abstraction to make ports easier
This commit is contained in:
+13
-9
@@ -104,7 +104,7 @@ WiFiManager::~WiFiManager() {
|
||||
|
||||
// AUTOCONNECT
|
||||
boolean WiFiManager::autoConnect() {
|
||||
String ssid = "ESP" + String(ESP.getChipId());
|
||||
String ssid = "ESP" + String(WIFI_getChipId());
|
||||
return autoConnect(ssid.c_str(), NULL);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ void WiFiManager::setupConfigPortal() {
|
||||
}
|
||||
|
||||
boolean WiFiManager::startConfigPortal() {
|
||||
String ssid = "ESP" + String(ESP.getChipId());
|
||||
String ssid = "ESP" + String(WIFI_getChipId());
|
||||
return startConfigPortal(ssid.c_str(), NULL);
|
||||
}
|
||||
|
||||
@@ -662,7 +662,7 @@ String WiFiManager::getScanItemOut(){
|
||||
if(tok_R) item.replace("{R}", (String)WiFi.RSSI(indices[i])); // rssi db
|
||||
if(tok_q) item.replace("{q}", (String)round(map(rssiperc,0,100,1,4))); //quality icon 1-4
|
||||
if(tok_i){
|
||||
if (enc_type != ENC_TYPE_NONE) {
|
||||
if (enc_type != WIFI_AUTH_OPEN) {
|
||||
item.replace("{i}", "l");
|
||||
} else {
|
||||
item.replace("{i}", "");
|
||||
@@ -888,7 +888,7 @@ void WiFiManager::handleInfo() {
|
||||
page += (String)((system_get_time() / 1000000)%60) + " secs";
|
||||
|
||||
page += F("<dt>Chip ID</dt><dd>");
|
||||
page += ESP.getChipId();
|
||||
page += WIFI_getChipId();
|
||||
page += F("</dd>");
|
||||
|
||||
page += F("<dt>Flash Chip ID</dt><dd>");
|
||||
@@ -1089,7 +1089,7 @@ void WiFiManager::handleReset() {
|
||||
|
||||
DEBUG_WM(F("RESETTING ESP"));
|
||||
delay(1000);
|
||||
ESP.reset();
|
||||
reboot();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1105,7 +1105,7 @@ void WiFiManager::handleErase() {
|
||||
page += _customHeadElement;
|
||||
page += FPSTR(HTTP_HEAD_END);
|
||||
|
||||
bool ret = ESP_eraseConfig();
|
||||
bool ret = WiFi_eraseConfig();
|
||||
if(!ret) DEBUG_WM(F("ERASE FAILED"));
|
||||
|
||||
// bool ret = reset = true;
|
||||
@@ -1113,7 +1113,7 @@ void WiFiManager::handleErase() {
|
||||
if(ret) page += F("Module will reset in a few seconds.");
|
||||
else {
|
||||
page += F("An Error Occured");
|
||||
DEBUG_WM(F("WiFi.eraseConfig reported an error"));
|
||||
DEBUG_WM(F("WiFi EraseConfig reported an error"));
|
||||
}
|
||||
|
||||
page += FPSTR(HTTP_END);
|
||||
@@ -1123,7 +1123,7 @@ void WiFiManager::handleErase() {
|
||||
|
||||
if(ret){
|
||||
DEBUG_WM(F("RESETTING ESP"));
|
||||
ESP.reset();
|
||||
reboot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1407,7 +1407,7 @@ bool WiFiManager::WiFi_enableSTA(bool enable) {
|
||||
|
||||
// erase config BUG polyfill
|
||||
// https://github.com/esp8266/Arduino/pull/3635
|
||||
bool WiFiManager::ESP_eraseConfig(void) {
|
||||
bool WiFiManager::WiFi_eraseConfig(void) {
|
||||
// return ESP.eraseConfig();
|
||||
|
||||
const size_t cfgSize = 0x4000;
|
||||
@@ -1419,4 +1419,8 @@ bool WiFiManager::ESP_eraseConfig(void) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void WiFiManager::reboot(){
|
||||
ESP.restart();
|
||||
}
|
||||
+15
-6
@@ -13,14 +13,22 @@
|
||||
#ifndef WiFiManager_h
|
||||
#define WiFiManager_h
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#endif
|
||||
|
||||
#include <DNSServer.h>
|
||||
#include <memory>
|
||||
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#if defined(ESP8266)
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#endif
|
||||
|
||||
#define WIFI_getChipId() ESP.getChipId()
|
||||
#define WIFI_AUTH_OPEN ENC_TYPE_NONE
|
||||
|
||||
const char HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang='en'><head><meta name='format-detection' content='telephone=no'><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>";
|
||||
@@ -113,6 +121,7 @@ class WiFiManager
|
||||
String getConfigPortalSSID();
|
||||
|
||||
void resetSettings();
|
||||
void reboot();
|
||||
|
||||
//sets timeout before AP,webserver loop ends and exits even if there has been no setup.
|
||||
//useful for devices that failed to connect at some point and got stuck in a webserver loop
|
||||
@@ -227,7 +236,7 @@ class WiFiManager
|
||||
bool WiFi_Disconnect();
|
||||
bool WiFi_enableSTA(bool enable);
|
||||
bool WiFi_enableSTA(bool enable,bool persistent);
|
||||
bool ESP_eraseConfig();
|
||||
bool WiFi_eraseConfig();
|
||||
void debugSoftAPConfig();
|
||||
|
||||
String getParamOut();
|
||||
|
||||
Reference in New Issue
Block a user