Comments (12)
Are you confusing mdns hostname and ssid, they are not the same thing.
I suppose there could be a global for setting apname, shrug seems trivial
from wifimanager.
The ondemand part is non blocking but not autoconnect is not in that example, // wm.setConfigPortalBlocking(false);
I see the millis rollover issue, thanks
Looks like you figured the rest out. I suggest you read the .h file the super example and the wiki https://github.com/tzapu/WiFiManager/wiki/Methods
The actual readme still needs work as do general docs
from wifimanager.
from wifimanager.
Its the first argument in the function.. what do you mean?
startConfigPortal(ssid,..
from wifimanager.
The initial post about the 686 line was with ESP32.
It also occurs with the ESP8266, in the line 388
// not connected start configportal
bool res = startConfigPortal(apName, apPassword);
At the beginning of Main there is wm.setHostname("MDNSEXAMPLE"), line 37, onDemandNonBlocking.ino.
Shouldn't the library have used this same "MDNSEXAMPLE" as the SSID?
from wifimanager.
It appears there is a way to read the SSID, but there is no way to Set it
/**
* get config portal AP SSID
* @since 0.0.1
* @access public
* @return String the configportal ap name
*/
String WiFiManager::getConfigPortalSSID() {
return _apName;
}
from wifimanager.
I managed to solve it, I was missing using:
autoConnect(apName, apPassword)
startConfigPortal(apName, apPassword)
char const * portal_SSID = {"DEVICE1"};
char const * portal_PASSWORD = {"12345678"}; // Need >= 8 chars
wm.autoConnect(portal_SSID, portal_PASSWORD);
wm.startConfigPortal(portal_SSID, portal_PASSWORD);
wm.autoConnect(portal_SSID, portal_PASSWORD);
wm.startConfigPortal(portal_SSID, portal_PASSWORD);
Maybe it would be easier if there was a function to set this, instead of the user declaring the SSID and password on each line they use when the portal starts.
Thank you.
from wifimanager.
Should the onDemandNonBlocking.ino example always be non-blocking?
If the ESP is not connected, how long will the portal wait to go to the loop() routine?
When I comment out the wm.autoConnect() line, then the led blinks, but if I leave the line, the portal is activated and remains active indefinitely.
I used wm.setConfigPortalTimeout(timeout), but it still takes the timeout time to go to loop().
from wifimanager.
Should the onDemandNonBlocking.ino example always be non-blocking?
If the ESP is not connected, how long will the portal wait to go to the loop() routine?
When I comment out the wm.autoConnect() line, then the led blinks, but if I leave the line, the portal is activated and remains active indefinitely.
I used wm.setConfigPortalTimeout(timeout), but it still takes the timeout time to go to loop().
The line needed to be uncommented:
// wm.setConfigPortalBlocking(false);
from wifimanager.
Should the onDemandNonBlocking.ino example always be non-blocking?
If the ESP is not connected, how long will the portal wait to go to the loop() routine?
When I comment out the wm.autoConnect() line, then the led blinks, but if I leave the line, the portal is activated and remains active indefinitely.
I used wm.setConfigPortalTimeout(timeout), but it still takes the timeout time to go to loop().The line needed to be uncommented:
// wm.setConfigPortalBlocking(false);
If I use the portal Timeout, how can I know if the portal has already been stopped?
Note: On line 599, a form of time control that is not recommended appears to be being implemented, in the case of recycling the variable returned to millis().
// handle timed out
if(millis() > _configPortalStart + _configPortalTimeout){
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(F("config portal has timed out"));
#endif
return true; // timeout bail, else do debug logging
}
But on line 607, A recommended form of time control is being implemented
// log timeout time remaining every 30s
if((millis() - timer) > logintvl){
timer = millis();
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(WM_DEBUG_VERBOSE,F("Portal Timeout In"),(String)((_configPortalStart + _configPortalTimeout-millis())/1000) + (String)F(" seconds"));
#endif
}
from wifimanager.
If I use the portal Timeout, how can I know if the portal has already been stopped?
I found this: getConfigPortalActive()
My sketch now (ESP8266):
- It works like a WiFi router, the user have to press the button for 15 seconds
-
- The settings are reset.
-
- Wait for user to release button.
-
- LED goes out (on NodeMCU off: HIGH)
- The portal is only active for the timeout period, to avoid unnecessary exposure of the portal.
- The LED flashes differently when the portal is active
Sketch:
#include <Arduino.h>
/**
* OnDemandNonBlocking.ino
* example of running the webportal or configportal manually and non blocking
* trigger pin will start a webportal for 120 seconds then turn it off.
* startAP = true will start both the configportal AP and webportal
*/
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
// include MDNS
#ifdef ESP8266
#include <ESP8266mDNS.h>
#elif defined(ESP32)
#include <ESPmDNS.h>
#endif
// select which pin will trigger the configuration portal when set to LOW
#define TRIGGER_PIN 0 // ESP8266 GPIO0 (NodeMCU D3)
#define LED_BUILTIN_D4 2 // ESP8266 GPIO2 (NodeMCU D4)
char const *portal_SSID = {"DEVICE1"};
char const *portal_PASSWORD = {"12345678"}; // Need >= 8 chars
WiFiManager wm;
unsigned int timeout = 120; // seconds to run for
unsigned int startTime = millis();
//bool portalRunning = false;
bool startAP = true; // start AP and webserver if true, else start only webserver
uint32_t millis1 = 0;
uint32_t millis2 = 0;
void doWiFiManager();
void setup()
{
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
// put your setup code here, to run once
Serial.begin(115200);
Serial.setDebugOutput(true);
delay(1000);
Serial.println("\n Starting");
pinMode(TRIGGER_PIN, INPUT_PULLUP);
pinMode(LED_BUILTIN_D4, OUTPUT);
digitalWrite(LED_BUILTIN_D4, HIGH);
wm.setConfigPortalTimeout(timeout);
// wm.resetSettings();
wm.setHostname("MDNSEXAMPLE");
// wm.setEnableConfigPortal(false);
wm.setConfigPortalBlocking(false);
// wm.autoConnect();
wm.autoConnect(portal_SSID, portal_PASSWORD);
}
void loop()
{
#ifdef ESP8266
MDNS.update();
#endif
doWiFiManager();
// put your main code here, to run repeatedly:
if (wm.getConfigPortalActive() == true)
{
if ((millis() - millis2) > 500)
{
millis2 = millis();
digitalWrite(LED_BUILTIN_D4, !digitalRead(LED_BUILTIN_D4));
}
} else {
if ((millis() - millis2) > 5000)
{
millis2 = millis();
}
if (((millis() - millis2) < 500))
{
digitalWrite(LED_BUILTIN_D4, LOW);
} else if (((millis() - millis2) > 500) && ((millis() - millis2) < 1000))
{
digitalWrite(LED_BUILTIN_D4, HIGH);
}
}
}
void doWiFiManager()
{
// is auto timeout portal running
if (wm.getConfigPortalActive()) //portalRunning
{
wm.process(); // do processing
// check for timeout
if ((millis() - startTime) > (timeout * 1000))
{
Serial.println("portaltimeout");
//portalRunning = false;
if (startAP)
{
wm.stopConfigPortal();
}
else
{
wm.stopWebPortal();
}
}
}
// is configuration portal requested?
if (digitalRead(TRIGGER_PIN) == LOW && (!wm.getConfigPortalActive())) // !portalRunning
{
// Minimum button press time to activate the portal
if ((millis() - millis1) > 15000)
{
digitalWrite(LED_BUILTIN_D4, HIGH);
// Wait for user to release button
while(digitalRead(TRIGGER_PIN) == LOW) {
yield();
}
if (startAP)
{
Serial.println("Button Pressed, Starting Config Portal");
wm.resetSettings();
wm.setConfigPortalBlocking(false);
wm.startConfigPortal(portal_SSID, portal_PASSWORD);
}
else
{
Serial.println("Button Pressed, Starting Web Portal");
wm.startWebPortal();
}
//portalRunning = true;
startTime = millis();
}
else
{
digitalWrite(LED_BUILTIN_D4, LOW);
}
}
else
{
millis1 = millis();
}
}
(Now I think I can go to the part "auto update via email")
Thank you.
from wifimanager.
Hello, I would like to suggest that an example be made available (if possible) with a login to access the portal, it is the standard for almost all routers I have seen, I found a project that has this, perhaps it could serve as an example of how to implement it :
https://github.com/rtek1000/esp32-asyncwebserver-fileupload-example/tree/master/example-02
Additional page that a commercial router shows if the user is unable to log in:
from wifimanager.
Related Issues (20)
- Possibility to change pass for SoftAP from webui.
- Feature configurable? WiFi AP started when local WiFi is down HOT 2
- How to save and restore Ip adress from webportal ?
- Dedicated Parameter Page HOT 1
- Unable to save/retrieve custom variables in WiFiManager
- Q: ESP Reboot after successful initial connection to own wifi possible (bind issue with Async Webserver from AP to STA)
- Esp32 wroom 32 UE
- Question: Is there a way to detect if the WiFi connection is successful before the config portal closes? HOT 1
- Force remove DNS input from Captive portal
- Question: Is possible change deep link to redirect to an App instead of Captive Portal HOT 3
- Add new Release to platformio HOT 5
- Custom Param doesn't load when starting ConfigPortal on demand & WiFi has been already connected.
- Hi
- How to refresh (repaint) custom param element on setValue() HOT 2
- unable to do OTA update for esp32 s3. update failed due to error in downloading version. unable to find the where the exact issue is?
- OTA UPDATE ISSUE HOT 1
- Changing STA config's authmode causes the STA config's SSID to become empty
- Custom configuration, on demand server, and invoking web server for future config updates
- Get stored SSID before connection is made, to connect to strongest of multiple identical SSIDs HOT 2
- CN language strings 界面设置为中文的解决办法 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wifimanager.