Monday, 22 August 2016

Receiving expiration messages for commands in IoT Hub

When you are dealing with devices in an IoT scenario, you want to ensure that you get a feedback to the commands you issued. Generally, the nature of the feedback itself depends on the type of IoT scenario you are trying to build. For example - if the device is tied to a building which sends out temperature readings of the rooms, it may not be necessary that the device receive a "ChangeTemperature" command immediately. It could very well be acceptable if it take up the command after a minute. However, imagine a scenario where you are trying to remotely control a moving object e.g. drone, toy car, ship, cattle, you may want to ensure that commands are received by the remote object quickly or you get to re-issue another command after the previous command has expired.

IoT Hub's service SDK provides a very useful API to receive feedback to every command that you issued.

1. Enable acknowledgement of the command when you issue it. If you are only looking for negative acknowledgements (expiration, rejection etc.) then set the acknowledgement enum to "NegativeOnly".


2. Start a feedback receiver and verify the status of the commands.



Now, when message expires before it is received by the device, you get a feedback with status "Expired" and you can re-issue the command if you like :).



No comments:

Post a Comment