简体   繁体   中英

Sending message from Android application to Azure IoT Hub device

I'm currently using Azure for a project. In this project I hava a Android Application and a IoT(NodeMCU 1.0) and I have found a way to send messages from the IoT Device to my android application using Azure, but now I have to send data from the Android application to the IoT device. the device is using IoT Hub to send information to Azure.

You could use IoT REST API to send a command to device from your android application. Refer https://www.codeproject.com/Articles/1113447/Azure-IOT-Hub-REST-API for more details.

Another reference: https://microsoft.github.io/techcasestudies/iot/2016/11/29/Agatsa.html

According to your description, based on my understanding, I think you want to send data from Android app to IoT device via the way of sending cloud-to-device messages of Azure IoTHub. You need to do two steps for implementing the needs.

First of all, there are two ways to implement for sending a cloud-to-device message to IoTHub.

  1. Directly sending data from Android App to IoTHub, you can refer to the section Send a cloud-to-device message of the offical tutorial for Java to do it, but I think it's not a good idea to do it between Android and IoTHub that considering the concurrency requests for IoTHub come from android devices installed your app.

  2. So per my experience, the better way is that create a Mobile App for Node.js which will handle the request from Android devices and forward the data to IoTHub via Send a cloud-to-device message using Node.js .

Then, you can try to call the REST API Receive Device Bound Notification using eLua or Arduino ino code at regular intervals on IoT devices to receive the c2d message, like the code in the section Receive messages in the simulated device app .

Hope it helps.

If you have to send data from Android device to Azure IoT Hub then please follow following Microsoft Articles

  1. Quickstart: Control a device connected to an IoT hub (Android)
  2. Quickstart: Send IoT telemetry from an Android device

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM