Open solideblock opened 12 months ago
Sorry, this is outside the scope of the library.
It easily gets complicated if you consider questions like:
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.
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.
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.
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.
The solution to this is probably to create the client object dynamically may be? I. e. instead of creating a static object like in the example (at global scope): ` const char* mqtt_server = "broker.mqtt-dashboard.com";
ESPPubSubClientWrapper client(mqtt_server); ` You can simply define a pointer to a client initialized with NULL
ESPPubSubClientWrapper *client = NULL;
Later (once the server name is known) you can create and assign the object at runtime:
` const char* serverName; // Pointer thats hold the server name...
//do something here to get a valid server name into the variable serverName
// then create the object...
client = new ESPPubSubClientWrapper(serverName);
`
whenever client is not NULL, you can use the methods of the API as usual, just make sure you check the client-pointer for not being NULL before dereferencing, like may be so:
// in void loop() if (NULL != client) client->loop();
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 !