Comments (7)
Hi @Juerd, could you please help me with my problem here :D Would be greatly appreciated.
from esp-wifisettings.
from esp-wifisettings.
Hello @Juerd, thanks for the fast reply. In the API reference section, you wrote,
void portal();
Normally, this function is called by .connect(). To allow reconfiguration after the initial configuration, you could call .portal() manually, for example when a button is pressed during startup.
I wish it would work like this. Unfortunately, when this function is called, the portal AP is opened and I'm able to connect to the AP but accessing the AP on the browser gives me a HTTP 500 error.
from esp-wifisettings.
from esp-wifisettings.
Hi @Juerd thanks for the code example, I'll try it out on my end to see if it works for me. Thank you and have a nice evening :D
from esp-wifisettings.
Hi @Juerd, so I've been trying to figure out why WiFiSettings.portal() is not working for me for my code usage. The code is as follows:
` // display device info on config page
WiFiSettings.hostname = device_ID;
WiFiSettings.heading("Device ID:");
WiFiSettings.heading(device_ID);
// Define custom settings saved by WifiSettings
// MQTT configuration variable to be shown on config UI provided by the WiFi Settings library
bool checkbox_mqtt_auth_dummy = WiFiSettings.checkbox("MQTT broker authentification");
String mqtt_brokeraddress_dummy = WiFiSettings.string("MQTT broker address", "mqtt.eclipse.org");
String mqtt_brokerauth_user = WiFiSettings.string("Username", "username");
String mqtt_brokerauth_pass = WiFiSettings.string("Password", "password");
// try to connect to WiFi with a timeout of 30 seconds - launch portal if connection fails
WiFiSettings.connect(true, -1);
// MQTT config
checkbox_mqtt_auth = checkbox_mqtt_auth_dummy;
Mqttbrokeraddress = mqtt_brokeraddress_dummy;
Mqtt_auth_username = mqtt_brokerauth_user;
Mqtt_auth_password = mqtt_brokerauth_pass;
//
// if user wants MQTT to be used, set the MQTT Broker, port number and the MQTT Client
MQTT_Client.setServer(Mqttbrokeraddress.c_str(), 1883);
MQTT_Client.setClient(hagerClient);
int retries = 0;
while (retries < 5)
{
retries++;
if (checkbox_mqtt_auth) // mqtt broker needs authentification data to connect
{
connected_tobroker = MQTT_Client.connect(device_ID, Mqtt_auth_username.c_str(), Mqtt_auth_password.c_str(), lwt_Topic.c_str(), 1, true, lwt_message.c_str());
}
else // mqtt broker doesnt need authentication to connect
{
connected_tobroker = MQTT_Client.connect(device_ID, lwt_Topic.c_str(), 1, true, lwt_message.c_str());
}
if (connected_tobroker)
{
Serial.println("Connected to MQTT Broker."); // successfully connected to broker
break;
}
else
{
Serial.println(retries);
Serial.println("Connecting to MQTT Broker failed... ");
Serial.print("failed, MQTT connection status =");
Serial.print(MQTT_Client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
if(!connected_tobroker) // if number of MQTT reconnection attempts exceeds the maximum retry limit, open the portal
{
Serial.println("Retries exceeded, restarting device");
WiFiSettings.portal(); // this doesnt work for some reason
}`
So the gist of the code is that I want the portal to be restarted again if the MQTT connection to the broker is not successful after a few tries. (User may have given wrong username or password for the broker connection on the portal or the MQTT broker is down). This is to ensure that I'm able to prevent the device from going into an infinite loop not doing anything and gives the user the option to fix the mistake.
The bug I found is that when I called the WiFiSettings.portal() method, I can see that the portal is up. I'm also able to connect to the soft AP (takes longer for some reason) but I'm unable to access the portal (HTTP ERROR 500). I also noticed that I cant see the debugging output in the serial monitor that usually shows up when I'm connected to device (eg. 13 WiFi Networks found).
It would be greatly appreciated if you could help me debug this because this library is really quite practical :D and I thank you again for your work.
Regards,
Ameer
from esp-wifisettings.
I don't know what's wrong.
from esp-wifisettings.
Related Issues (18)
- Warning in ESP8266 HOT 1
- Feature Request: Manual SSID HOT 3
- web interface HOT 4
- WiFiSettings.string() seems to encode the string in some way HOT 2
- WPS HOT 2
- MQTT client, PubSubClient HOT 1
- Compilation error with platform espressif8266 version 3.1.0 HOT 4
- Getting 255.255.255.255 as IP address HOT 4
- Didn't work with ESP32 C3 version HOT 12
- ESP32 does not connect unless restarted through portal HOT 2
- Drop down list on custom variables HOT 8
- Wifi AP hostname HOT 4
- Compile error with expansion of macro 'F' HOT 4
- Make filesystem configurable
- Having custom password fields in the AP config replace password with ***********s HOT 4
- SSID with apostrophe is truncated HOT 2
- arduino-esp32: Local IP is 255.255.255.255 after connection succeeds HOT 4
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 esp-wifisettings.