mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #137] Save Parameter with startConfigPortal #103
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#103
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @WilliamFrasson on GitHub (Mar 25, 2016).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/137
Hello
I find a problem tring to use the startConfigPortal adding parameters. Maybe i'm doing something wrong..
I'm using Arduino ide 1.6.8
esp8266 library 2.1,0
WiFiManager 0.10
code
WiFiManagerParameter custom_http_Cloud_Address("Http Cloud address", "Cloud Adress", g_stConfigDevice.cloud_address, sizeof(g_stConfigDevice.cloud_address));
WiFiManagerParameter custom_http_Cloud_Port("Http Cloud port", "Cloud Port", g_stConfigDevice.cloud_port, sizeof(g_stConfigDevice.cloud_port));
WiFiManagerParameter custom_Sensor_Temp("Temp Sensor", "Temp APi Sensor Api sign", g_stConfigDevice.sensor_apikey_Temp, sizeof(g_stConfigDevice.sensor_apikey_Temp));
WiFiManagerParameter custom_Sensor_Hum("Hum Sensor", "Hum Api Sign", g_stConfigDevice.sensor_apikey_Hum, sizeof(g_stConfigDevice.sensor_apikey_Hum));
//WiFiManager
//Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;
//set config save notify callback
wifiManager.setSaveConfigCallback(saveConfigCallback);
//add all your parameters here
wifiManager.addParameter(&custom_http_Cloud_Address);
wifiManager.addParameter(&custom_http_Cloud_Port);
wifiManager.addParameter(&custom_Sensor_Temp);
wifiManager.addParameter(&custom_Sensor_Hum);
b_saveConfigCallback = false;
//reset settings - for testing
//wifiManager.resetSettings();
//sets timeout until configuration portal gets turned off
//useful to make it all retry or go to sleep
//in seconds
wifiManager.setTimeout(120);
//wifiManager.setConfigPortalTimeout(180);
//it starts an access point with the specified name
//here "AutoConnectAP"
//and goes into a blocking loop awaiting configuration
if (!wifiManager.startConfigPortal("AppDHT_AccessPoint"))
{
DEBUG_PRINTLN("failed to connect and hit timeout");
delay(3000);
//reset and try again, or maybe put it to deep sleep
ESP.reset();
delay(5000);
}
Serial.println(wifiManager.getConfigPortalSSID());
if (b_saveConfigCallback)
{
bool ret_code;
...
LOG:
*WM: Http Cloud address
*WM: Adding parameter
*WM: Http Cloud port
*WM: Adding parameter
*WM: Temp Sensor
*WM: Adding parameter
*WM: Hum Sensor
*WM: SET AP
*WM:
*WM: Configuring access point...
*WM: AppDHT_AccessPoint
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM: 204 No Response
*WM: 204 No Response
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Handle root
*WM: Handle root
*WM: Handle root
*WM: Info
*WM: Sent info page
*WM: Info
*WM: Sent info page
*WM: Scan done
*WM: OneMorePeace
*WM: -44
*WM: Vodafone-WiFi
*WM: -91
*WM: Vodafone-30482066
*WM: -93
*WM: Sent config page
*WM: WiFi save
*WM: Parameter
*WM: Http Cloud address
*WM:
*WM: Parameter
*WM: Http Cloud port
*WM:
*WM: Parameter
*WM: Temp Sensor
*WM:
*WM: Parameter
*WM: Hum Sensor
*WM:
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 0
*WM: Failed to connect.
failed to connect and hit timeout
thanks in advance
William
@tzapu commented on GitHub (Mar 25, 2016):
hi,
i think that if it fails to connect, it does not call the save parameters callback. so you would need to remove that check.
if (b_saveConfigCallback)I can t see where from you are printing the wifi ssid and pass, but it does not look like it s connecting anyway, so something wrong there
to connect once it connected sucessfuly once, after config, on next boots you could just do
WiFi.begin();i hope this helps and thanks
@WilliamFrasson commented on GitHub (Mar 25, 2016):
Hello,
thanks for the hints.
Now i call WiFi.begin() instead of the WiFi.begin( ssid, password) . but i still see the problem of read-back the value of parameters added:
here the last log:
Connecting to AP................
*WM: Adding parameter
*WM: Http Cloud address
*WM: Adding parameter
*WM: Http Cloud port
*WM: Adding parameter
*WM: Temp Sensor
*WM: Adding parameter
*WM: Hum Sensor
*WM: SET AP
*WM:
*WM: Configuring access point...
*WM: AppDHT_AccessPoint
*WM: AP IP address:
*WM: 192.168.4.1
*WM: HTTP server started
*WM: 204 No Response
*WM: 204 No Response
*WM: 204 No Response
*WM: 204 No Response
*WM: Handle root
*WM: Sent config page
*WM: WiFi save
*WM: Parameter
*WM: Http Cloud address
*WM:
*WM: Parameter
*WM: Http Cloud port
*WM:
*WM: Parameter
*WM: Temp Sensor
*WM:
*WM: Parameter
*WM: Hum Sensor
*WM:
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 0
*WM: Failed to connect.
*WM: WiFi save
*WM: Parameter
*WM: Http Cloud address
*WM:
*WM: Parameter
*WM: Http Cloud port
*WM:
*WM: Parameter
*WM: Temp Sensor
*WM:
*WM: Parameter
*WM: Hum Sensor
*WM:
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Connection result:
*WM: 3
Save New Configuration...
Exit from Configuration Portal.
cloud_address:
cloud_port:
sensor_apikey_Temp:
sensor_apikey_Hum:
Start Saving New Configuration... OK!
Restart Module!
So it seem to don't readback the parameter
second) how i can print ssid and password.? i check in WiFiManager.h but i don't see any method ..
thanks in advanced
@WilliamFrasson commented on GitHub (Mar 26, 2016):
hello,
i found the error that was giving the problems over the .getValue when i added a my parameter (See below)
I use a ID composed of more than one world when added parameter,
for example : using id = ""Cloud Address", give the error documented above, while using "Cloud_Address" the .getValue return the expected value
// id/name placeholder/prompt default length -->
WiFiManagerParameter custom_http_Cloud_Address("Cloud_Address", "Cloud Adress", g_stConfigDevice.cloud_address, sizeof(g_stConfigDevice.cloud_address));
now i'm going to resolve the second problem: after a reset (por, or ESP.restart();) the device don't find the SSID and PASSWORD stored before ...
maybe some one have some idea about it?
@tzapu commented on GitHub (Mar 26, 2016):
hi, you can use the standard
to retreive whatever the SDK stored.
I would also encourage you to update to the latest github version of the lib, there s some fixes included for connection logic
@WilliamFrasson commented on GitHub (Mar 27, 2016):
Thaks for the hint (in the while i found it and use. :P)
Finally I'm now able to understand the what cause of loosing the SSID and PASSWORD configured using WiFiManager ;
I was calling the "WiFi.disconnect();" for save power by swithing off the radio side of the chip.
but this cause to loose permanently the wifi configuration stored...
I just check it using the printDialog metod:
WiFi.printDiag(Serial);
WiFi.disconnect();
WiFi.printDiag(Serial);
For my point of view WiFiDisconnect should not lost permanently the parameters but this is what i see also after a power on or a reset
From your point of view this behaviour is what one should expect or is some not so normal ..
here a log:
Mode: STA+AP
PHY mode: N
Channel: 11
AP id: 0
Status: 5
Auto connect: 1
SSID (9): NETGEAR22
Passphrase (16): yellowcartoon371
BSSID set: 0
WiFi status: 3
MAC: F1:B1:11:7F:CF:5C
SSID: NETGEAR22
Password: yellowcartoon371
Mode: STA+AP
PHY mode: N
Channel: 11
AP id: 0
Status: 0
Auto connect: 1
SSID (0):
Passphrase (0):
BSSID set: 0
thanks in advanced for any comments and suggestion;
@tzapu commented on GitHub (Mar 28, 2016):
hi, WiFi.disconnect() erasing parameters is something that has been established by the esp8266 core for arduino. I agree with you that it should not erase settings, there should be a separate function for that, but i guess they had their reasons...
feel free to open a issue with them, link it here...