In the earlier post MKR1000 Azure IoT Hub Interface using HTTP, I wrote about how to get the MKR1000 ready for Azure IoT Hub and start receiving data from Azure IoT. You might have noticed the following when running the sketch in the earlier post: After using the Device Explorer to send a single message, the MKR1000 would have blinked its LED after the first receive. If you continue to let the sketch run with out sending any new message, after about 60 seconds you will notice that MKR1000 receiving the same message and blinking again. This is due to the way a message’s life cycle works on the Azure IoT Hub. In this post I will address how the devices should send any one of Complete/Reject/Abandon message back to the Azure IoT Hub so that the message is not replayed again. This is essential if you are to interface with Azure IoT Hub correctly with HTTP.
After getting my hands on the pre-release version of the MKR1000 as part of the Worlds Largest Arduino Maker Challenge yesterday, I was trying to get it running with the Azure IoT Hub. This guide lays out some of the things that I learned that might help out others out there trying to get their projects running with Azure IoT.
This guide doesn’t use AMQP or MQTT. This uses the simple HTTP interfaces available for Azure IoT Hub. This assumes that you have already signed up for the Azure IoT Hub and created it. This guide will walk you through the following steps to get you going.
I was surprised to learn that AMQP protocol is not supported on Universal Windows Platform with Azure Devices Client libraries.I was getting this message “Amqp protocol is not supported” when trying to connect to the Microsoft Azure IoT Hub through the UWA app. This applies to MQTT as well. Only thing that’s supported right now is HTTP.
The nuget package Microsoft.Azure.Devices.Client lists both AMQP and MQTT libraries as dependencies. But its not supported on the Universal Windows platform. Weird.
This threw “Amqp protocol is not supported” :
__thisClient = DeviceClient.Create(__azureIoTHubHostname, new DeviceAuthenticationWithRegistrySymmetricKey(__azureIoTHubDeviceId, __azureIoTHubDeviceKey));
Had to update the line to include the TransportType.HTTP1 parameter:
__thisClient = DeviceClient.Create(__azureIoTHubHostname, new DeviceAuthenticationWithRegistrySymmetricKey(__azureIoTHubDeviceId, __azureIoTHubDeviceKey), TransportType.Http1);