3
votes

We need to connect Android Application with Azure IoT Hub to send the telemetry readings at continuous intervals. For this communication, we would need to register the device with Azure IoT Hub. This process is easy and smooth if we have few handful of devices to connect. But, the android app can be installed by anyone from Play Store. To register the device at run time, we can use another Azure service Azure IoT Hub Device Provisioning Service (DPS). But, the current SDKs that are available to connect with DPS belongs to C#, Node, Java etc.

Can anyone guide how we can connect android device/mobile phones to DPS and then send data to Azure IoT Hub?

FYI: So far, I have provisioned Azure IoT Hub, Azure IoT Hub Device Provisioning Service, linked my IoT Hub in DPS. Under Enrollment Groups, I have created a group and have "Symmetric Keys" with me to use.

References: This is good to start if android device is registered with Azure IoT Hub -> https://docs.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-android.

Please comment if you need any additional information.

TIA..

1
It sounds like you are using Kotlin? If that is the case have you evaluated the option of having a mix of Java and Kotlin in the same project?Alberto Vega
Another option is to do it from an Azure Function like mentioned in this thread. stackoverflow.com/questions/55473488/…Alberto Vega
Hi @AlbertoVega-MSFT Thanks for looking into this. First, we are not using Kotlin as the legacy code was written in Java and we are continuing with that. Second, I checked the linked you provided (thanks). But, the other user did not describe on how they are using Azure Functions for DPS. If you have any documentation link or sample which we can refer to register our Android Phone on the fly with Azure IoT Hub DPS then that will be a good help. For now, we are open with symmetric key or cert approach.Amnesh Goel
Hi I'm afraid that I could not find an official doc showing how to do this. You might get a good idea about the Azure Function approach with this post sandervandevelde.wordpress.com/2018/12/29/…Alberto Vega
Hi @AlbertoVega-MSFT Thanks for checking out. I'm taking a look at link you provided. I just wanted to give you more info that in our case we do not have real IoT devices to register with Azure IoT Hub using DPS but we are using "Android Phones" (for now, and later it will cover Apple Phones) as devices to register with Azure IoT Hub DPS. Whenever a user installs the application then we will need to register his phone (device) with Azure IoT Hub. If you have any references which deal with Android and Azure IoT Hub DPS then that will be a good help.Amnesh Goel

1 Answers

2
votes

I think maybe I'm missing the point. You said the app was written in Java, right? if so, can't you just use the Java DPS SDK? Here is a link to a sample https://github.com/Azure/azure-iot-sdk-java/tree/master/provisioning/provisioning-samples/provisioning-symmetrickey-sample

I'm probably missing your question.

if you can't use Java, then we also have guidance on how to do it over either raw MQTT, or via the DPS REST API. Let me know and I can link those samples too (but Java SDK is simpler)