in my setup() function I have:
bool save_config = false;
wm.setSaveConfigCallback([&]()
{
save_config = true;
});
This fails with an error: error: no matching function for call to 'WiFiManager::setSaveConfigCallback(setup()::__lambda1)'
However I also have:
wm.setAPCallback([](WiFiManager *)
{
configColor();
});
And this works!
Any ideas?
You need to call it like this:
wm.setSaveConfigCallback([]()
{
save_config = true;
});
Since setSaveConfigCallback doesn't take any arguments.
@DarkFox correct, I used this where save_config is a local variable:
bool save_config = false;
wm.setSaveConfigCallback([&]()
{
save_config = true;
});
It's supposed to capture the save_config variable so I don't need to make it global as its only used in this one function. Maybe its really a tool chain bug?
Yeah, I was in the same situation. I decided to just make it a static on my wifi handling class. It's not like I've got multiples of it anyway. Though it is poor style.
Should we not just add WiFiManager* to all callbacks?
fixed with #584
Most helpful comment
Should we not just add WiFiManager* to all callbacks?