EFWob / ESPPubSubClientWrapper

MIT License
3 stars 0 forks source link

How to define connection parameters before client starts #6

Open solideblock opened 7 months ago

solideblock commented 7 months ago

Hi,

I've been playing with the library for few hours and everything is working as described. But, (sorry, i'm a noob) I didn't find out how I could change the MQTT-Broker post boot of my ESP8266.

As far as I understand, you can't set the broker from a setting one could change from the web interface. It has to be hardcoded.

Is there any easy way to modify the connection settings once the ESP has booted and apply it (new broker, and everything else) ?

Same goes for loading user and password, an example would be very welcome. I see that the parameters exists in the library, but I simply don't understand yet how to use them.

Thanks for your help !

EFWob commented 7 months ago

Sorry, this is outside the scope of the library.

It easily gets complicated if you consider questions like:

  1. How should that API look like (a web interface needs a working WiFi connection in the first place and requires some layout in HTML at least)
  2. How would you validate the user input.
  3. What are recovery strategies if you specify wrong data (namely WiFi credentials)
  4. Managing the permanent storage of the last working credentials/host information

I am not aware of any good example in another public github projects that covers this issue in an easy way. I will leave this issue open some time to let others comment who can provide such a link but will not work on it.

proPonent commented 3 months ago

Use WifiManager which will spin up a temporary access point from which you can direct the device to connect to your networks SSID and login automatically. Credentials are saved without hard coding them.

I also got stuck on how to implement a user and password for logging into the mqtt broker but the solution is client.connect("CLIENT_ID_YOU_MAKE_UP","MQTT_BROKER_USER","MQTT_BROKER_PASSWORD");

Including this line in the demo code would help us noobs a lot.

lutzbellmann commented 1 week ago

I like the concept of this Wrapper, yet: is there any possibility to change/ set the server "after" constructing the object ESPPubSubClientWrapper? I am using a onboarding process for my smart thing, and the user submits the IP for the MQTT broker. I can't hard code it everytime.