如何在设备预配服务注册列表中映射IoTHub? -注册状态为“未分配"; [英] How do I map IoTHub in Device Provisioning Service enrollment list? - Enrollment status "unassigned"

查看:89
本文介绍了如何在设备预配服务注册列表中映射IoTHub? -注册状态为“未分配";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为"myDPS"的Azure 设备配置服务设置,物联网中枢与下方链接.

I have a Azure device provisioning service setup entitled "myDPS" and below IoT hubs are linked.

  1. IoTHub-Dev-Asia
  2. IoTHub-Prod-Europe

当前没有注册清单.我用来注册设备的以下C#代码

Currently there are no enrollment list. The below c# code I am using to enroll the device

private const string RegistrationId = "TestRegID";
private const string OptionalDeviceId = "Device1";
private const ProvisioningStatus OptionalProvisioningStatus = ProvisioningStatus.Enabled;
private const string SampleTpmEndorsementKey = "***"// Key generated using TPM Simulator

static async Task SetRegistrationDataAsync()
{
   Console.WriteLine("Starting SetRegistrationData");
   Attestation attestation = new TpmAttestation(SampleTpmEndorsementKey);
   IndividualEnrollment individualEnrollment = new 
   IndividualEnrollment(RegistrationId, attestation);
   individualEnrollment.DeviceId = OptionalDeviceId;
   individualEnrollment.ProvisioningStatus = OptionalProvisioningStatus;
   Console.WriteLine("\nAdding new individualEnrollment...");
   var serviceClient = ProvisioningServiceClient.CreateFromConnectionString(ServiceConnectionString);
   IndividualEnrollment individualEnrollmentResult =
    await  serviceClient.CreateOrUpdateIndividualEnrollmentAsync(individualEnrollment).ConfigureAwait(false);
    Console.WriteLine("\nIndividualEnrollment created with success.");
    Console.WriteLine(individualEnrollmentResult);
}

以上代码已成功将设备注册到DPS,但状态显示为未分配

The above code successfully enrolls the device to the DPS but status shows as unassigned

问题#1-未分配注册状态,有时显示为FAILED 状态:失败 错误代码:404201

Issue#1 - Enrollment status unassigned, sometimes shows FAILED Status: failed Error code: 404201

问题#2 解决上述问题后,我想进行一些配置,在其中可以指定哪个设备应映射到哪个IoT,以便该设备可以自动确定其目标IoT中心.

Issue#2 Once above issue resolved, then I would like to have some configuration where I can specify which device should map to which IoT, so that device can automatically decide it's target IoT hubs.

示例:

Device1-> IoTHub-Dev-Asia

Device1->IoTHub-Dev-Asia

Device2-> IoTHub-Dev-Asia

Device2->IoTHub-Dev-Asia

Device3-> IoTHub-Dev-Europe

Device3->IoTHub-Dev-Europe

我认为通过注册列表进行的静态配置可以帮助但不确定如何使用它?

I assume Static configuration via the enrollment list can help but not sure how to use it?

推荐答案

三种受支持的分配策略确定如何将设备分配给IoT中心:

The three supported allocation policies determine how devices are assigned to an IoT hub:

  1. 最低延迟:基于对设备的延迟最低的集线器,将设备调配到IoT中心.
  2. 加权平均分配(默认):链接的IoT中心同样有可能为其配备了设备.这是默认设置.如果仅将设备配置到一个IoT中心,则可以保留此设置.
  3. 通过注册列表进行静态配置:在注册列表中指定所需的IoT中心的优先级高于DPS级别的分配策略.
  1. Lowest latency: Devices are provisioned to an IoT hub based on the hub with the lowest latency to the device.
  2. Evenly weighted distribution (default): Linked IoT hubs are equally likely to have devices provisioned to them. This is the default setting. If you are provisioning devices to only one IoT hub, you can keep this setting.
  3. Static configuration via the enrollment list: Specification of the desired IoT hub in the enrollment list takes priority over the DPS-level allocation policy.

如果需要分配设备,则应使用一次对ProvisioningDeviceClient.RegisterAsync() API的调用.您可以参考样本在该示例中,您需要将RegistrationId替换为之前创建的那个.

If you need to assign the device ,you should use a single call to the ProvisioningDeviceClient.RegisterAsync() API. You can refer to the sample.In the sample, you need to replace the RegistrationId with that your created before.

这篇关于如何在设备预配服务注册列表中映射IoTHub? -注册状态为“未分配";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆