Best practices for sending IoT device command over MQTT?

0

I'm finding it oddly difficult to find a straightforward example, of how best to handle controlling an IoT device over MQTT. Best I've found so far in official AWS docs, is https://docs.aws.amazon.com/wellarchitected/latest/iot-lens/device-commands.html but that one goes off and basically says (use Device Shadow).

I'd prefer to do it myself directly over MQTT. .. If I can find code to point the way for me?

FYI, I'm using Python.

I did also find https://iotatlas.net/en/implementations/aws/command/command1/

It mentions (you probably want to use a transaction ID), but then doesnt show how that would be handled in the code :(

Edit: I dont just need to "send" the command. I need to have the status of the command properly handled, in a robust manner.

asked a year ago398 views
1 Answer
0

Hi - Thanks for reaching out. I would say start with this whitepaper to follow a design pattern https://docs.aws.amazon.com/whitepapers/latest/designing-mqtt-topics-aws-iot-core/mqtt-design-best-practices.html

Then you can look into Tutorial: Connecting a device to AWS IoT Core by using the AWS IoT Device SDK. It uses MQTT as an example with Python.

profile pictureAWS
EXPERT
answered a year ago
  • I dont need help merely "connecting to AWS MQTT". Or just "publishing a message". There's enough examples of that. As I said in my post, I need code specific to handling command and control of an IoT device, using pure MQTT. That means:

    • sending multiple commands over time to topic cmd/devicename/some-command-topic

    • receiving updates back as to the success or failure of each command running on the device.

    The AWS docs recommend using a transaction id. but I cant find a single example of working code that does this. I dont see anything specific to that in the references you gave.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions