-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non blocking AP mode #379
Comments
I've got the same requirement and from what I can tell, there isn't a way to do this in the current code today. |
Hi Guys, Is this feature added? am really in bad need for this. |
development branch //if this is set, portal will be blocking and wait until save or exit,
// is false user must manually `process()` to handle config portal
void setConfigPortalBlocking(boolean shouldBlock); example |
Hi, wifiManager.setAPStaticIPConfig(ip, gateway, subnet); |
yes and |
void loop() Thats it??? Oh god thanks Shawn, you really saved my @$$. 💯 |
Yeah I mean its development, and hardly tested... |
It should, what board? |
Sonoff Basic |
I mean what esp board? |
esp8266 |
esp8266 which one? |
ESP8266 V4.1 |
Hi Shawn, |
You are gonna have to turn on verbose compilation warnings or whatever adruino has to show some actual info |
@ANASOMARY you should update your board software from board manager. You should use 2.4.1 or newer one. |
@tablatronix thx for ur help. But I have one more question. Our esp connected to an router. After that I close the router. Then as suppose our esp come back to AP mode. When I connected ap of esp, it cannot handle http requests. Sorry for bad eng. |
not sure i understand |
Give me one more shot to explain it :) I have a esp8266 module. I'm using wifimanager development branch for nonblocking ap mode. its working great. Congrats. My problem is that ; when esp cannot access the router which esp connected before it come back to access mode as expected. And I connect the AutoConnectAP with my computer to configure my esp for another router. But esp cannot answer my http request. |
in addition if you reset your router which esp connected. Esp disconnected from router and enabling its ap. After your router started. Esp connect the router succesfully but esp dont close its ap. Briefly if you restart your router, your esp will enable its ap mode. After your router come back esp will connect it but dont close its ap. |
Yeah the ap stays running, the portal only runs if you reboot. |
Hmm so that means if our router stop working we need to restart our esp physically? Or can we understand that esp disconnected from router. For restarting programmatically. |
I will test some more |
I added some overflow fixes try now |
Will try now and let you know. |
Hi tablatronix, i've just tested, not working, now, even the parameters are not showing up, this is my code: #include <FS.h>
#include <ESP8266WiFi.h> //ESP8266 Core WiFi Library (you most likely already have this in your sketch)
#include <DNSServer.h> //Local DNS Server used for redirecting all requests to the configuration portal
#include <ESP8266WebServer.h> //Local WebServer used to serve the configuration portal
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
#include <ArduinoJson.h>
WiFiManager wifiManager;
WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
char mqtt_server[40] = "0.0.0.0";
char mqtt_topicIN[80] ="IOT_Device/IN";
char mqtt_topicOUT[80] ="IOT_Device/OUT";
char mqtt_port[6] = "1883";
/*
void handleRoot() {
wifiManager.startWebPortal();
}
void handleReset() {
server.send(200, "text/plain", "Resetting!");
//Serial.println("diconnecting client and wifi");
//client.disconnect();
wifi_station_disconnect();
WiFiManager wifiManager;
wifiManager.resetSettings();
ESP.reset();
}
void handleNotFound(){
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
*/
void setup()
{
Serial.begin(115200);
Serial.println("Setup mode...");
//wifiManager.resetSettings();
gotIpEventHandler = WiFi.onStationModeGotIP([](const WiFiEventStationModeGotIP & event)
{
Serial.print("Station connected, IP: ");
Serial.println(WiFi.localIP());
});
disconnectedEventHandler = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected & event)
{
Serial.println("Station disconnected!");
});
WiFiManagerParameter custom_text1("<p><b>MQTT Settings</b></p>");
WiFiManagerParameter custom_mqtt_server("server", "Server IP", mqtt_server, 40);
WiFiManagerParameter custom_mqtt_port("port", "Port", mqtt_port, 6);
WiFiManagerParameter custom_mqtt_topicIN("topicIn", "Input Topic", mqtt_topicIN, 80);
WiFiManagerParameter custom_mqtt_topicOUT("topicOut", "Output Topic", mqtt_topicOUT, 80);
wifiManager.addParameter(&custom_text1);
wifiManager.addParameter(&custom_mqtt_server);
wifiManager.addParameter(&custom_mqtt_port);
wifiManager.addParameter(&custom_mqtt_topicIN);
wifiManager.addParameter(&custom_mqtt_topicOUT);
wifiManager.setConfigPortalBlocking(false);
wifiManager.autoConnect("IOT Device");
/*
server.on("/", handleRoot);
server.on("/inline", []()
{
server.send(200, "text/plain", "this works as well");
});
server.on("/resetwifi", handleReset);
server.onNotFound(handleNotFound);
server.begin();
*/
Serial.println("HTTP server started");
}
void loop()
{
wifiManager.process();
Serial.println("hello world");
// put your main code here, to run repeatedly:
} Now, even if you take the setConfigPortalBlocking, the parameters are no longer showing up. In the serial I got this: *WM: <- Request redirected to captive portal |
There you go Your wifiparameter objects need to be global or in scope, once setup exits, the references are broken. If anyone has better ideas how to do this, I am open to it. You can make your parameters static, or define them outside of |
Hi Tablatronix, |
works for me #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
WiFiManager wm;
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "servername", 40);
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "1234", 6);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(3000);
//WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
// add a custom input field
WiFiManagerParameter custom_field("customfield", "Custom Field", "Default Value", 40);
WiFiManagerParameter custom_token("api_token", "api token", "0123456789", 9); // overflow
// WiFiManagerParameter custom_tokenb("invalid token", "invalid token", "abcdefghijk", 11);
//add all your parameters here
wm.addParameter(&custom_mqtt_server);
wm.addParameter(&custom_mqtt_port);
wm.addParameter(&custom_field);
wm.addParameter(&custom_token);
// wm.addParameter(&custom_tokenb); // overflow
//reset settings - wipe credentials for testing
//wm.resetSettings();
wm.setConfigPortalBlocking(false);
if(wm.autoConnect("AutoConnectAP")){
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
}
else
{
Serial.println("non blocking config portal running");
}
wm.startConfigPortal("OnDemandAP");
}
void loop() {
wm.process();
// put your main code here, to run repeatedly:
}
|
this is giving *WM: [ERROR] WiFiManagerParameter is out of scope .. Am I doing something wrong? #include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
WiFiManager wm;
char mqtt_server[40] = "0.0.0.0";
char mqtt_topicIN[80] ="IOT_Device/IN";
char mqtt_topicOUT[80] ="IOT_Device/OUT";
char mqtt_port[6] = "1883";
WiFiManagerParameter custom_mqtt_server("server", "Server IP", mqtt_server, 40);
WiFiManagerParameter custom_mqtt_port("port", "Port", mqtt_port, 6);
WiFiManagerParameter custom_mqtt_topicIN("topicIn", "Input Topic", mqtt_topicIN, 80);
WiFiManagerParameter custom_mqtt_topicOUT("topicOut", "Output Topic", mqtt_topicOUT, 80);
void setup()
{
Serial.begin(115200);
delay(3000);
Serial.println("Setup mode...");
//wifiManager.resetSettings();
wm.addParameter(&custom_mqtt_server);
wm.addParameter(&custom_mqtt_port);
wm.addParameter(&custom_mqtt_topicIN);
wm.addParameter(&custom_mqtt_topicOUT);
wm.setConfigPortalBlocking(false);
if(wm.autoConnect("IOT_Device"))
{
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
}
else
{
Serial.println("non blocking config portal running");
}
wm.startConfigPortal("IOT_Device");
}
void loop()
{
wm.process();
//Serial.println("hello world");
// put your main code here, to run repeatedly:
} |
testing |
I am on esp32, should I test on 8266 also ? |
Can you please try on the 8266? Is the one I am using |
Will do |
Hi tablatronix, were you able to test it on the esp8266 ? Parameters are not showing up :( |
Yeah works fine there as well. |
It's working only with the version I had from last Friday, when I download the newer version it doesn't work |
This was just patched this morning, there was a bug if you were not setting a default value, maybe that was causing an issue. |
Hi! |
setConfigPortalTimeout is not implemented when configPortal is non blocking, because you are in control of it, and can stop it when you want |
Thank you much for work, It seems in the example, onDemandNonBlocking, setConfigPortalBlocking(false); missing... |
Hi @tablatronix, how to setup ap name in noblocking without autoconnect? tnx |
You mean on demand? |
can this be closed? |
Yes |
I try using this code, how to fix it? NodeMCU v3 |
I have a project that requires the ESP8266 to startup in access point mode, but the remaining code is blocked till the access point is configured.
Is there any way to continue with the code, and still have access point available in the background?
The text was updated successfully, but these errors were encountered: