esp-mqtt
esp-mqtt copied to clipboard
Support multiple instances in parallel
Hi,
I'd like to be able to have multiple instances of the esp-mqtt client running in parallel.
Adding this support seems simple enough, as the lwmqtt library and the connection support code here already seems to handle multiple instances just fine. So I likely only need to change esp_mqtt.c
.
Before I make those changes in esp_mqtt.c
and open a pull request, I'd like to ask for some quick feedback:
- I guess you want to keep backwards compatibility? So current dunctions should be kept and should probably forward to the new functions, using a single global client instance?
- How should I name the new functions? Those will mirror the current function API 1:1 but take an additional context argument as first parameter. Just add
2
to the function names?
Hi, thanks for looking into this! It would be nice to keep the global client API around long-term as mosts projects do not require multiple clients. I would suggest creating a client oriented API in "esp_mqtt_client.{c,h}" and then use this API for implementing the global client. The functions could have the following syntax `esp_mqtt_client_publish(esp_mqtt_client * client, ...).