[GH-ISSUE #762] setSaveParamsCallback() Hanging and not being able to save parameters #636

Closed
opened 2026-02-28 01:26:19 +03:00 by kerem · 15 comments
Owner

Originally created by @martinberlin on GitHub (Nov 1, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/762

Hardware

WiFimanager Branch/Release:

  • Development

Esp8266

  • ESP8266 Wemos D1

ESP Core Version: 2.4.0, staging

  • staging (master/dev)

Description

I have already a working version without using this new "param" in the menu on my FS2 Project and it's working fine. Also I though it could be a nice idea to let the users to edit the Setup without touching the connection but I'm struggling with it.

The logic could be the same as setSaveConfigCallback()

  wm.setBreakAfterConfig(true); // Without this saveConfigCallback does not get fired
  wm.setSaveConfigCallback(saveConfigCallback);

So this saveConfigCallback sets a flag like in your example shouldSaveConfig to true, and then IF (shouldSaveConfig) is true, then we save this in SPIFFS or whatever medium you use to save your configuration.
Well, it turns out that for me in the current state acts the same as saveConfigCallback except that it hangs after returning. So I can never get to save the settings.

Settings in IDE

Module: Wemos D1

Additional libraries:

This is the feature branch where I tried to integrate this:
https://github.com/martinberlin/FS2/compare/feature/param?expand=1

Debug Messages

>>>>> Selected Camera model is: OV2640
SPIFFS file system mounted
Reading config file
{"timelapse":"30","slave_cam_ip":"","upload_host":"api.slosarek.eu","upload_path":"/upload.php?f=2018","jpeg_size":"1600x1200"}
parsed json
>>>>>>>>>ONLINE Mode
*WM: [3] allocating params bytes: 20
*WM: [2] Added Parameter: timelapse
*WM: [2] Added Parameter: slave_cam_ip
*WM: [2] Added Parameter: upload_host
*WM: [2] Added Parameter: upload_path
*WM: [2] Added Parameter: jpeg_size
CAM can't get online. Entering config mode. Please connect to access point CAM-autoconnect
CAM-autoconnect
[CALLBACK] saveParamCallback fired -> should save config is TRUE
 ets Jan  8 2013,rst cause:2, boot mode:(1,6)
 ets Jan  8 2013,rst cause:4, boot mode:(1,6)
wdt reset
Originally created by @martinberlin on GitHub (Nov 1, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/762 #### Hardware **WiFimanager Branch/Release:** - [ ] Development **Esp8266** - [ ] ESP8266 Wemos D1 **ESP Core Version: 2.4.0, staging** - [ ] staging (master/dev) ### Description I have already a working version without using this new "param" in the menu on my FS2 Project and it's working fine. Also I though it could be a nice idea to let the users to edit the Setup without touching the connection but I'm struggling with it. The logic could be the same as setSaveConfigCallback() ``` wm.setBreakAfterConfig(true); // Without this saveConfigCallback does not get fired wm.setSaveConfigCallback(saveConfigCallback); ``` So this saveConfigCallback sets a flag like in your example shouldSaveConfig to true, and then IF (shouldSaveConfig) is true, then we save this in SPIFFS or whatever medium you use to save your configuration. Well, it turns out that for me in the current state acts the same as saveConfigCallback except that it hangs after returning. So I can never get to save the settings. ### Settings in IDE Module: Wemos D1 Additional libraries: This is the feature branch where I tried to integrate this: https://github.com/martinberlin/FS2/compare/feature/param?expand=1 ### Debug Messages ``` >>>>> Selected Camera model is: OV2640 SPIFFS file system mounted Reading config file {"timelapse":"30","slave_cam_ip":"","upload_host":"api.slosarek.eu","upload_path":"/upload.php?f=2018","jpeg_size":"1600x1200"} parsed json >>>>>>>>>ONLINE Mode *WM: [3] allocating params bytes: 20 *WM: [2] Added Parameter: timelapse *WM: [2] Added Parameter: slave_cam_ip *WM: [2] Added Parameter: upload_host *WM: [2] Added Parameter: upload_path *WM: [2] Added Parameter: jpeg_size CAM can't get online. Entering config mode. Please connect to access point CAM-autoconnect CAM-autoconnect [CALLBACK] saveParamCallback fired -> should save config is TRUE ets Jan 8 2013,rst cause:2, boot mode:(1,6) ets Jan 8 2013,rst cause:4, boot mode:(1,6) wdt reset ```
kerem closed this issue 2026-02-28 01:26:19 +03:00
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

You are not saving though, you are doing something odd here.

if (memory.saveParamCallback) {
wm.startConfigPortal(configModeAP);
} else {
wm.autoConnect(configModeAP);
}

<!-- gh-comment-id:435227887 --> @tablatronix commented on GitHub (Nov 2, 2018): You are not saving though, you are doing something odd here. if (memory.saveParamCallback) { wm.startConfigPortal(configModeAP); } else { wm.autoConnect(configModeAP); }
Author
Owner

@martinberlin commented on GitHub (Nov 2, 2018):

I knew I was doing something stupid ;) Ok but then how it should be?
I read should be only one of both. So I can only call autoConnect? But that one will connect automatically if we are on the same WiFi.
Can you please make me a 3 lines example.

But even if I’m doing this wrong it’s not supposed to hang or I’m thinking it wrong?

<!-- gh-comment-id:435282047 --> @martinberlin commented on GitHub (Nov 2, 2018): I knew I was doing something stupid ;) Ok but then how it should be? I read should be only one of both. So I can only call autoConnect? But that one will connect automatically if we are on the same WiFi. Can you please make me a 3 lines example. But even if I’m doing this wrong it’s not supposed to hang or I’m thinking it wrong?
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

not sure what you are wanting that to do, how are you saving your params now? just use that instead

if (memory.saveParamCallback) {
// get params and save them to whereever
}

no idea why you are trying to restart the configportal

what does saving parameters have to do with autoconnect or startconfigportal ?

<!-- gh-comment-id:435380252 --> @tablatronix commented on GitHub (Nov 2, 2018): not sure what you are wanting that to do, how are you saving your params now? just use that instead if (memory.saveParamCallback) { // get params and save them to whereever } no idea why you are trying to restart the configportal what does saving parameters have to do with autoconnect or startconfigportal ?
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

hmm I guess I am confused as to what this is doing

you are setting
shouldSaveConfig = true; so that is good

what is purpose of
memory.saveParamCallback = false;

<!-- gh-comment-id:435381975 --> @tablatronix commented on GitHub (Nov 2, 2018): hmm I guess I am confused as to what this is doing you are setting ` shouldSaveConfig = true;` so that is good what is purpose of `memory.saveParamCallback = false;`
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

are you wanting to start the configportal if it was never setup before?
is that what that flag marks?

I would set that flag after you successfully save params.

<!-- gh-comment-id:435383441 --> @tablatronix commented on GitHub (Nov 2, 2018): are you wanting to start the configportal if it was never setup before? is that what that flag marks? I would set that flag after you successfully save params.
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

oh ok I think I might know what the problem is, save params does not stop the configportal.

I thought you were using non blocking mode, you are using blocking loop.

This makes sense now.

hmm, I may have to make some modifications to this to allow it to work with blocking mode, since there is no way to stop the configportal after the page gets served to user. Also you might not want to close the configportal.

let me think about this for a little bit, if you want to change your code to non blocking it will be a bit of work to move some stuff around.

<!-- gh-comment-id:435388461 --> @tablatronix commented on GitHub (Nov 2, 2018): oh ok I think I might know what the problem is, save params does not stop the configportal. I thought you were using non blocking mode, you are using blocking loop. This makes sense now. hmm, I may have to make some modifications to this to allow it to work with blocking mode, since there is no way to stop the configportal after the page gets served to user. Also you might not want to close the configportal. let me think about this for a little bit, if you want to change your code to non blocking it will be a bit of work to move some stuff around.
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

ok for now you will have to use exit button after save, it should work.

<!-- gh-comment-id:435394241 --> @tablatronix commented on GitHub (Nov 2, 2018): ok for now you will have to use exit button after save, it should work.
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

I updated code, you can now call
wm.stopConfigPortal(); if you want to stop the configportal when blocking

so you can do

void saveParamCallback(){
  Serial.println("[CALLBACK] saveParamCallback fired");
  // wm.stopConfigPortal(); // will abort cp after page is sent
}

If you want to close the cp after saving params, until you can rewrite for non blocking

<!-- gh-comment-id:435413043 --> @tablatronix commented on GitHub (Nov 2, 2018): I updated code, you can now call `wm.stopConfigPortal();` if you want to stop the configportal when blocking so you can do ```C++ void saveParamCallback(){ Serial.println("[CALLBACK] saveParamCallback fired"); // wm.stopConfigPortal(); // will abort cp after page is sent } ``` If you want to close the cp after saving params, until you can rewrite for non blocking
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

do you know how to specify pins for OV2640 ?
I have one of these, I might be able to run your code on it.

61hliynhx2l sl1200 1

<!-- gh-comment-id:435415358 --> @tablatronix commented on GitHub (Nov 2, 2018): do you know how to specify pins for OV2640 ? I have one of these, I might be able to run your code on it. ![61hliynhx2l _sl1200_ 1](https://user-images.githubusercontent.com/807787/47924139-193b4280-de89-11e8-9d9e-8094c2c670bc.jpg)
Author
Owner

@martinberlin commented on GitHub (Nov 2, 2018):

Ah ok now I understand. Yes that was a flag to say: Hey in next restart please start with WM in Config mode.
I will try it out thank you very much!

Yeah basically what I was trying to do is to restart the App and call WiFi manager just to enter the Setup. By the way there would be a way in the future to offer some kind of interface, so you can do this param edition from your application instead of starting again (And having to connect to the Accesspoint and so on ?)

<!-- gh-comment-id:435416039 --> @martinberlin commented on GitHub (Nov 2, 2018): Ah ok now I understand. Yes that was a flag to say: Hey in next restart please start with WM in Config mode. I will try it out thank you very much! Yeah basically what I was trying to do is to restart the App and call WiFi manager just to enter the Setup. By the way there would be a way in the future to offer some kind of interface, so you can do this param edition from your application instead of starting again (And having to connect to the Accesspoint and so on ?)
Author
Owner

@martinberlin commented on GitHub (Nov 2, 2018):

do you know how to specify pins for OV2640 ?

That might be a nightmare. Because the guys of Arducam just specified the Chip Select (CS) in the demo sketches. All the rest, unless I see it very wrong, is hardcoded in the ArduCam library itself. You can take a look here in their demos for ESP32 (That's one of those ?)
https://github.com/ArduCAM/ArduCAM_ESP32S_UNO/tree/master/libraries/ArduCAM/examples/ESP32

But I would anyways try it out! What kind of camera is that, can you send me the Specs page ?
For sure it comes with some example. I would not mind to branch my stuff and add an adapter for this one, then you can have a very small Spycam 👍

<!-- gh-comment-id:435417589 --> @martinberlin commented on GitHub (Nov 2, 2018): >do you know how to specify pins for OV2640 ? That might be a nightmare. Because the guys of Arducam just specified the Chip Select (CS) in the demo sketches. All the rest, unless I see it very wrong, is hardcoded in the ArduCam library itself. You can take a look here in their demos for ESP32 (That's one of those ?) https://github.com/ArduCAM/ArduCAM_ESP32S_UNO/tree/master/libraries/ArduCAM/examples/ESP32 But I would anyways try it out! What kind of camera is that, can you send me the Specs page ? For sure it comes with some example. I would not mind to branch my stuff and add an adapter for this one, then you can have a very small Spycam 👍
Author
Owner

@tablatronix commented on GitHub (Nov 2, 2018):

I see thanks.

There is not yet a way to pass the webserver into WM, but the wm webserver is a public shared pointer, so you can use it in your code, and add events to it etc.

see DEV/ondemandconfigportal example


wm.setWebServerCallback(bindServerCallback); // called after webserver is setup

void bindServerCallback(){
  wm.server->on("/custom",handleRoute);
  // wm.server->on("/info",handleRoute); // can override wm!
}

void handleRoute(){
  Serial.println("[HTTP] handle route");
  wm.server->send(200, "text/plain", "hello from user code");
}
<!-- gh-comment-id:435418767 --> @tablatronix commented on GitHub (Nov 2, 2018): I see thanks. There is not yet a way to pass the webserver into WM, but the wm webserver is a public shared pointer, so you can use it in your code, and add events to it etc. see DEV/ondemandconfigportal example ```c++ wm.setWebServerCallback(bindServerCallback); // called after webserver is setup void bindServerCallback(){ wm.server->on("/custom",handleRoute); // wm.server->on("/info",handleRoute); // can override wm! } void handleRoute(){ Serial.println("[HTTP] handle route"); wm.server->send(200, "text/plain", "hello from user code"); } ```
Author
Owner

@martinberlin commented on GitHub (Nov 2, 2018):

Ah great I will try it out!
After looking some pointers, I guess MOSI / MISO and Clock should be the same so maybe it's not so hard to get this working with a different camera.
But of course it's time debugging and so on. I hope in 2 weeks will arrive my demo and you can connect this one I hope without to much effort first to some ESP8266 based board...And then if you want to ESP32 but I still didn't tested that. Today they arrived two Makerbot ESP32 boards so I will have some fun on the weekend :)

<!-- gh-comment-id:435421323 --> @martinberlin commented on GitHub (Nov 2, 2018): Ah great I will try it out! After looking some pointers, I guess MOSI / MISO and Clock should be the same so maybe it's not so hard to get this working with a different camera. But of course it's time debugging and so on. I hope in 2 weeks will arrive my demo and you can connect this one I hope without to much effort first to some ESP8266 based board...And then if you want to ESP32 but I still didn't tested that. Today they arrived two Makerbot ESP32 boards so I will have some fun on the weekend :)
Author
Owner

@martinberlin commented on GitHub (Nov 2, 2018):

I tried to simplify stuff:
github.com/martinberlin/FS2@ba0255be1a

But still calling the route: /paramsave brings a crash

[CALLBACK] saveParamCallback fired -> should save config is TRUE
Fatal exception 28(LoadProhibitedCause):
epc1=0x402195f9, epc2=0x00000000, epc3=0x00000000, excvaddr=0x000000a8, depc=0x00000000

Exception (28):
epc1=0x402195f9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x000000a8 depc=0x00000000

ctx: cont
sp: 3ffffaa0 end: 3fffffc0 offset: 01a0

UPDATE: Typical I forgot making a git pull on your lib before testing this. Newbie mistake !!! ;)
Great ! Now it works perfectly.
I will test it again to make sure and close it down with an example

<!-- gh-comment-id:435467590 --> @martinberlin commented on GitHub (Nov 2, 2018): I tried to simplify stuff: https://github.com/martinberlin/FS2/commit/ba0255be1a72d3528bc134f229bab212603bd693 But still calling the route: /paramsave brings a crash [CALLBACK] saveParamCallback fired -> should save config is TRUE Fatal exception 28(LoadProhibitedCause): epc1=0x402195f9, epc2=0x00000000, epc3=0x00000000, excvaddr=0x000000a8, depc=0x00000000 Exception (28): epc1=0x402195f9 epc2=0x00000000 epc3=0x00000000 excvaddr=0x000000a8 depc=0x00000000 ctx: cont sp: 3ffffaa0 end: 3fffffc0 offset: 01a0 UPDATE: Typical I forgot making a git pull on your lib before testing this. Newbie mistake !!! ;) Great ! Now it works perfectly. I will test it again to make sure and close it down with an example
Author
Owner

@martinberlin commented on GitHub (Nov 2, 2018):

Fantastic! Checked it two times, now it saves config correctly without hanging. Thanks a lot!
If anyone wants to see the implementation please check this branch on my camera project:
https://github.com/martinberlin/FS2/blob/feature/param/FasarekFS2/FasarekFS2.ino

<!-- gh-comment-id:435475813 --> @martinberlin commented on GitHub (Nov 2, 2018): Fantastic! Checked it two times, now it saves config correctly without hanging. Thanks a lot! If anyone wants to see the implementation please check this branch on my camera project: https://github.com/martinberlin/FS2/blob/feature/param/FasarekFS2/FasarekFS2.ino
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#636
No description provided.