tzapu / WiFiManager

ESP8266 WiFi Connection manager with web captive portal
http://tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/
MIT License
6.45k stars 1.94k forks source link

Customfields saved values not display on portal #1623

Open zstergios opened 1 year ago

zstergios commented 1 year ago

When I configure the settings are saved and everything works great, if I start the portal to change some settings, the last saved values are not display and default value is displayed.

The thrid parameter is default value. I expected to see the last saved value instead. Is it bug or I missing something?

#BEGIN
  WiFiManagerParameter custom_weburl("weburl", "Web URL","https://NAME.domain.com", 128, "placeholder=\"Web URL\"");
  wm.addParameter(&custom_weburl);

  wm.setSaveParamsCallback(saveParamCallback);
  wm.setMinimumSignalQuality(10);
  wm.setConfigPortalTimeout(180);
  //wm.setConfigPortalBlocking(true);
#END

Debug Messages

messages here
tablatronix commented 1 year ago

you have to restore saved values, wm doesnt know what you saved

zstergios commented 1 year ago

How to restore them?

This way causes restarts

String getParam(String name){
  //read parameter from server, for customhmtl input
  String value;
  if(wm.server->hasArg(name)) {
    value = wm.server->arg(name);
  }
  return value;
}

and that way returns empty value probably because it's before adding the "custom_weburl" to wm.addParameter

  const char* url =  custom_weburl.getValue();
  WiFiManagerParameter custom_weburl("weburl", "Web URL",url, 128, "placeholder=\"Web URL\"");
zenz commented 4 months ago

if(wm.server->hasArg(name)) { value = wm.server->arg(name); } return value; } there's a bug, since wm.server at that moment is equal to nullptr. then you cannot get the custom_field value.

tablatronix commented 4 months ago

What do you mean? Thats called in a callback whats the scope here?

zenz commented 4 months ago

What do you mean? Thats called in a callback whats the scope here?

you can just try to compile and run the Advanced samples, while using custom_field, if you want to get custom_field value, it will crash, since wm.server is equal to nullptr.

tablatronix commented 3 months ago

Still not sure what you are calling, this happens in the example with no changes?

zenz commented 3 months ago

while compile and running this sample https://github.com/tzapu/WiFiManager/blob/master/examples/Advanced/Advanced.ino

you will find that custom field value with name "customfieldid" cannot be get and store, at that moment calling wm.server, it's nullptr. you will never have a chance to use hasArg or arg to check and get the value.

tablatronix commented 3 months ago

But its only called from the callback is it not?