A device can interact with AWS IoT using MQTT pub/sub alone. This mode is preferred if the device is extremely resource constrained and does not want to do any string or JSON parsing of Thing Shadow protocol. The sample_apps subscribe_publish_sample.c is a good place to start.
Any time if you would like to just use the MQTT interface without shadow, include the aws_iot_mqtt_interface.h file . This file has all the APIs needed for a device to communicate with the AWS IoT Platform
Connection Management
aws_iot_mqtt_connect()
aws_iot_mqtt_disconnect()
Publishing message
aws_iot_mqtt_publish()
Subscribe to a topic filter
aws_iot_mqtt_subscribe()
aws_iot_mqtt_unsubscribe()
Yield(background MQTT tasks)
aws_iot_mqtt_yield()
Generally this function could be called in a separate thread and all the callbacks will be called from the context of this thread. Other threads can publish.
- Note
- In a multi-threaded environment always acquire a lock before performing any operation on the MQTT library. This library is not thread safe.
Known Issues
- AWS IoT Platform does not currently support QoS2
- The Publish of QoS 1 messages will be blocking and any message that is not PUBACK will be delivered to the callback if the topic was subscribed. This is not expected in the publish function and should happen only in the aws_iot_mqtt_yield(). This will be fixed in the future revisions. The same is true for SUBACK.
- Retained flag of published message is not supported
Configuration associated with MQTT layer
#AWS_IOT_MQTT_TX_BUF_LEN
#AWS_IOT_MQTT_RX_BUF_LEN
#AWS_IOT_MQTT_NUM_SUBSCRIBE_HANDLERS