aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
977 stars 628 forks source link

Device shadow implementation in existing MQTT protocol. #1908

Open raviraj78 opened 5 months ago

raviraj78 commented 5 months ago

How to implement the device shadow property in the existing mqtt protocol. Hey actually i have a project in which mqtt is implemented, i want to use the device shadow property in this. And we are doing all the stuffs from the device side like registering things, subs/pubs topics, and the things is getting updated dynamically after the fleet provisioning of different devices. How to proceed with it, we are not using any sdk or anything. we are just doing it in a embedded c language.

AniruddhaKanhere commented 5 months ago

Hello @raviraj78,

If you have created thing in IoT core and have a functional MQTT library which can connect to AWS IoT, then you can use the Device Shadow feature. It is independent of whether you are using SDK or not.

You can update/create/get the device shadow by publishing/subscribing as necessary to the reserved topics listed here.

You can read about the device shadow service in depth here. Your application must utilize the timestamp/version fields of the JSON/cbor document received to make sure that there are no race conditions in case there are multiple updates to the device shadow.

You can use the https://github.com/aws/Device-Shadow-for-AWS-IoT-embedded-sdk library to create and match the topic string related to your device. It might make your application a bit simpler.

Thanks, Aniruddha