-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Pnp convention helper class (#184)
- Update README with instructions on how to use it.
- Loading branch information
1 parent
f51c2ae
commit b0b6a34
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
nanoFramework.Azure.Devices.Client/PlugAndPlay/PnpConvention.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using System; | ||
|
||
namespace nanoFramework.Azure.Devices.Provisioning.Client.PlugAndPlay | ||
{ | ||
/// <summary> | ||
/// A helper class for formatting the DPS device registration payload, per plug and play convention. | ||
/// </summary> | ||
public static class PnpConvention | ||
{ | ||
/// <summary> | ||
/// Create the DPS payload to provision a device as plug and play. | ||
/// </summary> | ||
/// <remarks> | ||
/// For more information on device provisioning service and plug and play compatibility, | ||
/// and PnP device certification, see <see href="https://docs.microsoft.com/azure/iot-pnp/howto-certify-device"/>. | ||
/// The DPS payload should be in the format: | ||
/// <c> | ||
/// { | ||
/// "modelId": "dtmi:com:example:modelName;1" | ||
/// } | ||
/// </c> | ||
/// For information on DTDL, see <see href="https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md"/> | ||
/// </remarks> | ||
/// <param name="modelId">The Id of the model the device adheres to for properties, telemetry, and commands.</param> | ||
/// <returns>The DPS payload to provision a device as plug and play.</returns> | ||
/// <exception cref="ArgumentNullException">If modelId is <see langword="null"/> or <see cref="string.Empty"/>.</exception> | ||
public static string CreateDpsPayload(string modelId) | ||
{ | ||
if (string.IsNullOrEmpty(modelId)) | ||
{ | ||
throw new ArgumentNullException(); | ||
} | ||
|
||
return $"{{\"modelId\":\"{modelId}\"}}"; | ||
} | ||
} | ||
} |