Recommendations for MQTT Library with ESPIDF
Recommendations for MQTT Library with ESPIDF
Seems there are a number of choices for mqtt client libraries. Can anyone give their input on one versus the other. I'm using Eclipse with ESPIDF (for ESP32) in c++. The libraries I was looking at include Paho Mqtt C, ESPMQTT (Tuanpmt), ESP-MQTT (base on lwmqtt) and the aws-iot.
Starting off with simple connection to local mosquitto broker.
thanks for the input/opinions.
Starting off with simple connection to local mosquitto broker.
thanks for the input/opinions.
Re: Recommendations for MQTT Library with ESPIDF
Hello rwel59,
Which library did you choose? Are you happy with your choice? What is your opinion about libraries other then you choose?
Thanks for reply...
Ozanhan Anac
Which library did you choose? Are you happy with your choice? What is your opinion about libraries other then you choose?
Thanks for reply...
Ozanhan Anac
Re: Recommendations for MQTT Library with ESPIDF
Hi Ozanhan,
Since this post was originally made last year, the esp-mqtt library has been integrated into ESP-IDF.
There is some documentation here:
https://docs.espressif.com/projects/esp ... /mqtt.html
And some examples here:
https://github.com/espressif/esp-idf/tr ... ocols/mqtt
This is the officially recommended and supported MQTT library for ESP-IDF.
Since this post was originally made last year, the esp-mqtt library has been integrated into ESP-IDF.
There is some documentation here:
https://docs.espressif.com/projects/esp ... /mqtt.html
And some examples here:
https://github.com/espressif/esp-idf/tr ... ocols/mqtt
This is the officially recommended and supported MQTT library for ESP-IDF.
Re: Recommendations for MQTT Library with ESPIDF
Is the esp-mqtt library thread safe?
I don't find locking mechanism in the esp-mqtt library code.
So I'm wondering if it is ok to call esp_mqtt_client_publish() in another task?
The example code calls esp_mqtt_client_publish() in mqtt_event_handler() when got MQTT_EVENT_CONNECTED, that is fine because it's executed by mqtt_task.
However, it's very common a user application need to create another task to regularly (or with some customized logic) send publish data.
-
- Posts: 14
- Joined: Sat Dec 05, 2015 7:59 am
Re: Recommendations for MQTT Library with ESPIDF
Hi @axellin,axellin wrote: ↑Mon Nov 26, 2018 5:19 amIs the esp-mqtt library thread safe?
I don't find locking mechanism in the esp-mqtt library code.
So I'm wondering if it is ok to call esp_mqtt_client_publish() in another task?
The example code calls esp_mqtt_client_publish() in mqtt_event_handler() when got MQTT_EVENT_CONNECTED, that is fine because it's executed by mqtt_task.
However, it's very common a user application need to create another task to regularly (or with some customized logic) send publish data.
The outbox for MQTT needs to be implemented to re-send the failed packet. Currently esp-mqtt directly writes data to the socket without reading from the outbox. Then, there are no semaphore needed to protect the outbox (read/write from difference threads). I think the next release, the MQTT client will support outbox storage.
Thanks.,
Re: Recommendations for MQTT Library with ESPIDF
Hi @ESP_tuanpmESP_tuanpm wrote: ↑Mon Nov 26, 2018 8:56 am
Hi @axellin,
The outbox for MQTT needs to be implemented to re-send the failed packet. Currently esp-mqtt directly writes data to the socket without reading from the outbox. Then, there are no semaphore needed to protect the outbox (read/write from difference threads). I think the next release, the MQTT client will support outbox storage.
Thanks.,
I think it's not about re-send the failed packet.
The esp-mqtt library is *not* thread safe at all.
Just think about 2 tasks calling any of esp_mqtt_client_subscribe()/esp_mqtt_client_unsubscribe()/esp_mqtt_client_ping()/ esp_mqtt_client_publish() APIs at the same time on differnct CPU, All the client->mqtt_state.* fields can be racy.
This needs fix.
-
- Posts: 14
- Joined: Sat Dec 05, 2015 7:59 am
Re: Recommendations for MQTT Library with ESPIDF
Thank @axellin to correct me the right problem. Yes, these need to fix asapaxellin wrote: ↑Tue Nov 27, 2018 3:20 am
Hi @ESP_tuanpm
I think it's not about re-send the failed packet.
The esp-mqtt library is *not* thread safe at all.
Just think about 2 tasks calling any of esp_mqtt_client_subscribe()/esp_mqtt_client_unsubscribe()/esp_mqtt_client_ping()/ esp_mqtt_client_publish() APIs at the same time on differnct CPU, All the client->mqtt_state.* fields can be racy.
This needs fix.
Re: Recommendations for MQTT Library with ESPIDF
Is the mqtt library now included with espidf usable with AWS mqtt? If so, are there any examples available?
Re: Recommendations for MQTT Library with ESPIDF
Does anyone have any input for this. Trying to figure what the best route is for using espidf with aws iot...
Re: Recommendations for MQTT Library with ESPIDF
https://github.com/espressif/esp-idf/tr ... ls/aws_iot
I am working on some project curently and I can tell that it's good base to start with AWS IoT.
I am working on some project curently and I can tell that it's good base to start with AWS IoT.
Who is online
Users browsing this forum: No registered users and 191 guests