tzapu / WiFiManager

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

WiFiManager and painlessMesh together #850

Open kbssa opened 5 years ago

kbssa commented 5 years ago

Anyone here have tried to combine WiFiManager and painlessMesh or at least know that is it feasable to use both in the same code.

My application really needs the WiFiManager captive portal like, but I have no idea on how to implement it with the painlessMesh.

If anyone coulp point me to the right direction, I would appreciate a lot.

pranjal-joshi commented 4 years ago

I also have similar requirements. My logic is to attempt a direct connection with wifi station firstly. If wifi is unable to connect then switch to mesh mode. It would be great to hear about updates about this from you!

pranjal-joshi commented 4 years ago

@kbssa Have you succeeded in using both of them together? I found that WiFiManager is very buggy to use. So i used ESPAsyncWebServer lib to create my own web server and with the help of ArduinoJson, I am writing my config on the SPIFFS of ESP8266! Hope this helps! :)

tablatronix commented 4 years ago

What is painless mesh ?

pranjal-joshi commented 4 years ago

What is painless mesh ?

@tablatronix painlessMesh is a library that creates a mesh network of ESPs so that they can communicate with each other without router. Link to the painlessMesh library

tablatronix commented 4 years ago

So why would you use this with wm if its not networking based? Or even how would you ?

pranjal-joshi commented 4 years ago

So why would you use this with wm if its not networking based? Or even how would you ?

Certainly it can be used along with external WiFi networks as well. As ESP provides MODE_AP_STA, My design is considers connecting to a WiFi network to access MQTT broker directly. But if WiFi is weak or unavailable due to range issues, I will enter into mesh mode so that I can send MQTT packets over the mesh to a node which is also connected to internet, thus effectively considering that node as a bridge node of the mesh network.

tablatronix commented 4 years ago

I still do not get it, its 2 seperate things, what would prevent them from working togather? Its the same as using 2 libraries.

pranjal-joshi commented 4 years ago

I still do not get it, its 2 separate things, what would prevent them from working together? Its the same as using 2 libraries.

I never said that these 2 libs are not compatible with each other. I think @kbssa was asking for a logical approach to implement this, maybe like a pseudo-code! Bdw, @tablatronix Please fix the ESP requires hard reset issue. This made me switch from WM to another library.

tablatronix commented 4 years ago

What do you mean ESP requires hard reset? There is no issue for that..

tablatronix commented 4 years ago

I will see about creating an example for combinging with painlessmesh and espmesh or espnow

pranjal-joshi commented 4 years ago

What do you mean ESP requires hard reset? There is no issue for that..

While using WM v2.0.2, I faced the issue that after receiving the config, the ESP still stays in blocking mode (even though it successfully saves the config in the memory). However, with a hard reset/power-cycle, the ESP successfully retrieves config from memory and proceeds as expected.

pranjal-joshi commented 4 years ago

I will see about creating an example for combinging with painlessmesh and espmesh or espnow

  • [ ] example candidate

@tablatronix - This might be a good point to take a look before writing an example. https://github.com/gmag11/painlessMesh/blob/master/examples/mqttBridge/mqttBridge.ino

tablatronix commented 4 years ago

are you saving parameters and not wifi? you have to set shoudBreak true or else it doesnt stop the cp, or switch to using the setup menu and not wifi for custom params.

Its not a bug but kind of a throwback to v.0 that I have not figured out a good way to fix without breaking old code. ( since you are NOW allowed to skip saving wifi everytime )

pranjal-joshi commented 4 years ago

@tablatronix Good to know about this. In my sketch, I was trying to save both WiFi config (SSID+PASS) along with 4-5 custom params which are to be stored on SPIFFS. If you didn't have mentioned about shouldBreak in the docs, please consider it so.

tablatronix commented 4 years ago

Ill try to find a better fix for this this week and add better callbacks for param saves.

I thought it was added to the readme but I am not seeing it ... hmm

tablatronix commented 4 years ago

doh it was added to hotfixes ill adjust that...

Save settings
This gets called when custom parameters have been set AND a connection has been established. Use it to set a flag, so when all the configuration finishes, you can save the extra parameters somewhere.

IF YOU NEED TO SAVE PARAMETERS EVEN ON WIFI FAIL OR EMPTY, you must set setBreakAfterConfig to true, or else saveConfigCallback will not be called.

//if this is set, it will exit after config, even if connection is unsuccessful.
    void          setBreakAfterConfig(boolean shouldBreak);
tablatronix commented 4 years ago

You should test out

  // wm.setParamsPage(true); // move params to seperate page, not wifi, do not combine with setmenu!, use setSaveParamsCallback
kubitz commented 3 years ago

I will see about creating an example for combinging with painlessmesh and espmesh or espnow

  • [ ] example candidate

@tablatronix - This might be a good point to take a look before writing an example. https://github.com/gmag11/painlessMesh/blob/master/examples/mqttBridge/mqttBridge.ino

@pranjal-joshi did you end up implementing this in one of your projects?

markg85 commented 2 years ago

I'm curious about this too. Contrary to what was said in this post earlier, I do think mesh an wifimanager should be complementary if you have a root node that lives on your normal network too. Kind of a gateway node into your mesh network.

In that case, the root node has normal plain wifi and needs to be configured as such. Hence the need for something like WifiManager.

An example with mesh + WifiManager would be an awesome starting point!

hemangjoshi37a commented 2 years ago

I am curious if anyone already has this implemented in their project: painlessmesh and wifimanager coming together. Please let me know because I am trying this to do this from very long time. Hemang Joshi