mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
add info page ota update
This commit is contained in:
+23
-2
@@ -1116,7 +1116,11 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){
|
||||
// DEBUG_WM(DEBUG_DEV,"scanNetworks async:",async == true);
|
||||
// DEBUG_WM(DEBUG_DEV,_numNetworks,(millis()-_lastscan ));
|
||||
// DEBUG_WM(DEBUG_DEV,"scanNetworks force:",force == true);
|
||||
if(force || _numNetworks == 0 || (millis()-_lastscan > 60000)){
|
||||
if(_numNetworks == 0){
|
||||
DEBUG_WM(DEBUG_DEV,"NO APs found forcing new scan");
|
||||
force = true;
|
||||
}
|
||||
if(force || (millis()-_lastscan > 60000)){
|
||||
int8_t res;
|
||||
_startscan = millis();
|
||||
if(async && _asyncScan){
|
||||
@@ -1126,6 +1130,7 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){
|
||||
using namespace std::placeholders; // for `_1`
|
||||
WiFi.scanNetworksAsync(std::bind(&WiFiManager::WiFi_scanComplete,this,_1));
|
||||
#else
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("WiFi Scan SYNC started"));
|
||||
res = WiFi.scanNetworks();
|
||||
#endif
|
||||
#else
|
||||
@@ -1135,6 +1140,7 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("WiFi Scan SYNC started"));
|
||||
res = WiFi.scanNetworks();
|
||||
}
|
||||
if(res == WIFI_SCAN_FAILED) DEBUG_WM(DEBUG_ERROR,"[ERROR] scan failed");
|
||||
@@ -1566,6 +1572,10 @@ void WiFiManager::handleInfo() {
|
||||
if(infoids[i] != NULL) page += getInfoData(infoids[i]);
|
||||
}
|
||||
page += F("</dl>");
|
||||
if(_showInfoUpdate){
|
||||
page += HTTP_PORTAL_MENU[8];
|
||||
page += HTTP_PORTAL_MENU[9];
|
||||
}
|
||||
if(_showInfoErase) page += FPSTR(HTTP_ERASEBTN);
|
||||
if(_showBack) page += FPSTR(HTTP_BACKBTN);
|
||||
page += FPSTR(HTTP_HELP);
|
||||
@@ -1768,7 +1778,7 @@ String WiFiManager::getInfoData(String id){
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTPD CALLBACK root or redirect to captive portal
|
||||
* HTTPD CALLBACK exit, closes configportal if blocking, if non blocking undefined
|
||||
*/
|
||||
void WiFiManager::handleExit() {
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP Exit"));
|
||||
@@ -1777,6 +1787,7 @@ void WiFiManager::handleExit() {
|
||||
page += FPSTR(S_exiting); // @token exiting
|
||||
server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length()));
|
||||
server->send(200, FPSTR(HTTP_HEAD_CT), page);
|
||||
delay(2000);
|
||||
abort = true;
|
||||
}
|
||||
|
||||
@@ -1884,7 +1895,9 @@ void WiFiManager::stopCaptivePortal(){
|
||||
// @todo maybe disable configportaltimeout(optional), or just provide callback for user
|
||||
}
|
||||
|
||||
// HTTPD CALLBACK, handle close, stop captive portal, if not enabled undefined
|
||||
void WiFiManager::handleClose(){
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Disabling Captive Portal"));
|
||||
stopCaptivePortal();
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP close"));
|
||||
handleRequest();
|
||||
@@ -2408,6 +2421,14 @@ void WiFiManager::setShowInfoErase(boolean enabled){
|
||||
_showInfoErase = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle showing update upload web ota button on info page
|
||||
* @param boolean enabled
|
||||
*/
|
||||
void WiFiManager::setShowInfoUpdate(boolean enabled){
|
||||
_showInfoUpdate = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* set menu items and order
|
||||
* if param is present in menu , params will be removed from wifi page automatically
|
||||
|
||||
+6
-2
@@ -298,7 +298,10 @@ class WiFiManager
|
||||
|
||||
// show erase wifi onfig button on info page, true
|
||||
void setShowInfoErase(boolean enabled);
|
||||
|
||||
|
||||
// show OTA upload button on info page
|
||||
void setShowInfoUpdate(boolean enabled);
|
||||
|
||||
// set ap channel
|
||||
void setWiFiAPChannel(int32_t channel);
|
||||
|
||||
@@ -437,6 +440,7 @@ class WiFiManager
|
||||
boolean _scanDispOptions = false; // show percentage in scans not icons
|
||||
boolean _paramsInWifi = true; // show custom parameters on wifi page
|
||||
boolean _showInfoErase = true; // info page erase button
|
||||
boolean _showInfoUpdate = true; // info page update button
|
||||
boolean _showBack = false; // show back button
|
||||
boolean _enableConfigPortal = true; // use config portal if autoconnect failed
|
||||
const char * _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS
|
||||
@@ -454,7 +458,7 @@ class WiFiManager
|
||||
// cache time helps throttle this
|
||||
// async enables asyncronous scans, so they do not block anything
|
||||
// the refresh button bypasses cache
|
||||
boolean _preloadwifiscan = true; // preload wifiscan if true
|
||||
boolean _preloadwifiscan = false; // preload wifiscan if true
|
||||
boolean _asyncScan = false; // perform wifi network scan async
|
||||
unsigned int _scancachetime = 30000; // ms cache time for background scans
|
||||
|
||||
|
||||
+2
-1
@@ -61,6 +61,7 @@ const char HTTP_SAVED[] PROGMEM = "<div class='msg'>Saving Credential
|
||||
const char HTTP_PARAMSAVED[] PROGMEM = "<div class='msg S'>Saved<br/></div>";
|
||||
const char HTTP_END[] PROGMEM = "</div></body></html>";
|
||||
const char HTTP_ERASEBTN[] PROGMEM = "<br/><form action='/erase' method='get'><button class='D'>Erase WiFi Config</button></form>";
|
||||
const char HTTP_UPDATEBTN[] PROGMEM = "<br/><form action='/update' method='get'><button>Update</button></form>";
|
||||
const char HTTP_BACKBTN[] PROGMEM = "<hr><br/><form action='/' method='get'><button>Back</button></form>";
|
||||
|
||||
const char HTTP_STATUS_ON[] PROGMEM = "<div class='msg S'><strong>Connected</strong> to {v}<br/><em><small>with IP {i}</small></em></div>";
|
||||
@@ -209,7 +210,7 @@ const char S_titlereset[] PROGMEM = "Reset";
|
||||
const char S_titleerase[] PROGMEM = "Erase";
|
||||
const char S_titleclose[] PROGMEM = "Close";
|
||||
const char S_options[] PROGMEM = "options";
|
||||
const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again.";
|
||||
const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again.\n";
|
||||
const char S_staticip[] PROGMEM = "Static IP";
|
||||
const char S_staticgw[] PROGMEM = "Static Gateway";
|
||||
const char S_staticdns[] PROGMEM = "Static DNS";
|
||||
|
||||
Reference in New Issue
Block a user