Skip to content

Commit 7cba956

Browse files
authored
Merge pull request #93974 from chrissie926/master
Add how-to-send-additional-data
2 parents 082d361 + 439617f commit 7cba956

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: How to transfer additional data between device and Azure Device Provisioning Service
3+
description: This document describes how to transfer additional data between device and DPS
4+
author: menchi
5+
ms.author: menchi
6+
ms.date: 10/29/2019
7+
ms.topic: conceptual
8+
ms.service: iot-dps
9+
services: iot-dps
10+
---
11+
12+
# How to transfer additional data between device and DPS
13+
Sometimes DPS needs more data from devices to properly provision them to the right IoT Hub, and that data needs to be provided by the device. Vice versa, DPS can return data to the device to facilitate client side logics.
14+
15+
## When to use it
16+
This feature can be used as an enhancement for [custom allocation](https://docs.microsoft.com/azure/iot-dps/how-to-use-custom-allocation-policies). For instance, you want to allocate your devices based on the device model without human intervention. In this case, you will use [custom allocation](https://docs.microsoft.com/azure/iot-dps/how-to-use-custom-allocation-policies). You can configure the device to report the model information as part of the [register device call](https://docs.microsoft.com/rest/api/iot-dps/runtimeregistration/registerdevice). DPS will pass the device’s information into to the custom allocation webhook. And your function can decide which IoT Hub this device will go to when it receives device model information. Similarly, if the webhook wishes to return some data to the device, it will pass the data back as a string in the webhook response.
17+
18+
## Device sends data to DPS
19+
When your device is sending a [register device call](https://docs.microsoft.com/rest/api/iot-dps/runtimeregistration/registerdevice) to DPS. The register call can be enhanced to take other fields in the body. The body looks like the following:
20+
```
21+
{
22+
“registrationId”: “mydevice”,
23+
“tpm”:
24+
{
25+
“endorsementKey”: “stuff”,
26+
“storageRootKey”: “things”
27+
},
28+
“interfaces”: “TODO: get how interfaces are reported by devices from PnP folks.”,
29+
“data”: “your additional data goes here. It can be nested JSON.”
30+
}
31+
```
32+
33+
## DPS returns data to the device
34+
If the custom allocation policy webhook wishes to return some data to the device, it will pass the data back as a string in the webhook response. The change is in the returnData section below.
35+
```
36+
{
37+
"iotHubHostName": "sample-iot-hub-1.azure-devices.net",
38+
"initialTwin": {
39+
"tags": {
40+
"tag1": true
41+
},
42+
"properties": {
43+
"desired": {
44+
"tag2": true
45+
}
46+
}
47+
},
48+
"returnData": "whatever is returned by the webhook"
49+
}
50+
```
51+
52+
## SDK support
53+
This feature is available in C, C#, JAVA and Node.js [client SDKs](https://docs.microsoft.com/azure/iot-dps/).
54+
55+
## Next steps
56+
* Develop using the [Azure IoT SDK]( https://github.com/Azure/azure-iot-sdks) for Azure IoT Hub and Azure IoT Hub Device Provisioning Service

articles/iot-dps/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@
142142
href: how-to-legacy-device-symm-key.md
143143
- name: Use SDK tools for development
144144
href: how-to-use-sdk-tools.md
145+
- name: How to send additional data from devices
146+
href: how-to-send-additional-data.md
145147
- name: Troubleshooting
146148
href: how-to-troubleshoot-dps.md
147149
- name: Reference

0 commit comments

Comments
 (0)