-
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
Accessing portal after connected to local wifi #656
Comments
Ondemandwebportal example |
Hi tablatronix, |
it is an example... |
Yes, I know, but i am struggling to get the correct code, can I please ask you some little help on how can i do it? |
When do you want it to turn on? What is the logic |
I want to turn it on every time i access it's ip address on the local network |
So leave it on all the time? |
Yes, and accessing the configuration portal through the local network and not by the auto generated wifi of the device |
so after your wifi connect code, or after checking to make sure wifi is connected however you are doing that just wm.startWebPortal, and wm.process() in your loop |
done! Thanks man, you're awesome! I am sharing the code here so I can help someone who get's the same problem i did. #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);
WiFiManagerParameter custom_mqtt_messages("messages", "Messages Topic", mqtt_topicOUT, 80);
ESP8266WebServer server(80);
void handleRoot()
{
wm.startWebPortal();
}
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.addParameter(&custom_mqtt_messages);
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");
server.on("/", handleRoot);
server.begin();
}
void loop()
{
wm.process();
server.handleClient();
//Serial.println("hello world");
// put your main code here, to run repeatedly:
} |
startconfigportal already starts the webserver, you are starting it twice |
if you want to only start the webportal when the ap has a client you can use this.
|
changed it! thanks again :) |
So that handleroot is not necessary, also a few people have tried to run a webserver and wm at the same time and have not had much success |
I am noticing now, that if I comment the startConfigPortal on the setup void, and keep the handleroot as it was, when i go to the device IP it does not open the wifimanager no more. is it asking too much if you could tell me what I need to change in the code? I just want to start the webportal when i acess the IP on the local network |
You cant detect "access the ip" unless you have a server running, so not exactly sure what you are trying to do or why. You cannot do both, either start configportal(softap+webportal) or start webserver(webportal) maybe the webportal wont start if you already have one running on port 80 |
I am trying to explain my best, my english is not that good i guess :) I just wanted that once the ESP is connected to the local network, i can access the webportal without the wifiManager launch the AP mode. When i call the startWebPortal(), the ESP is creating an AP, which I don't want. can i call the startWebPortal without the wifiManager creating a AP? |
startWebPortal should not start an AP, however the esp will start an AP if it got saved to flash. Add |
It's now working perfectly, here's the code: WiFiManager wm; //############################################# CUSTOM PARAMETERS FOR THE WIFI MANAGER ########################################## WiFiManagerParameter custom_mqtt_server("server", "Server IP", mqtt_server, 40); //################################################### GENERAL VARIABLES ######################################################### void handleNotFound() /*
wm.setConfigPortalBlocking(blockWM); if(wm.autoConnect(ssid.c_str())) // call the code down to activate wifi so users can configure the device, event if it's connected to the local network /*
void setup() setupDeviceWM(); void loop() |
@vaz83 |
it is possible to put a password for access, example login acess portal? |
Basic Infos
Hardware
WiFimanager Branch/Release: Development
Esp8266/Esp32:
Hardware: NodeMCU ESP8266 Lua WiFi Internet Development Board
Core Version: 2.4.0, staging
Description
Hi, can anyone tell me how to access the webportal in runtime? I have seen some examples around here but to acess the webpage the user needs to push a button and then connect to the wifi created by the wifiManager. What i would need is after the wifiManager is configured and available on my local network, every time i enter its address on the web browser, it opens by default the configuration portal. Is is possible?
The text was updated successfully, but these errors were encountered: