peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
549 stars 116 forks source link

Is it possible to use your driver with a WiFi manager library? #96

Closed faisal-saddique closed 1 year ago

faisal-saddique commented 1 year ago

I was thinking of using a WiFi manager library like this one with your async MQTT driver but wasn't sure if I could do it because the constructor of mqtt_as asks for WiFi credentials to connect to, which I don't have hardcoded in my code. Any help would be highly appreciated.

ebolisa commented 1 year ago

I use it all the time!! Just create a function to read the credentials from wifi.dat when needed 😉

faisal-saddique commented 1 year ago

Thank you for answering, @ebolisa!

I was also thinking of doing the same. But let's say if we have more than 1 credentials stored in the wifi.dat file, what be the approach then?

ebolisa commented 1 year ago

Just need to cycle trough them. In a project I’m saving the ip, subnet, dns, etc as well. In another, I’m saving the Blynk token. Of course, I had to modify the wifimng.py to collect additional data.

faisal-saddique commented 1 year ago

Okay, thank you!