0

我想为我的设备使用 Azure 中的设备预配。

我正在使用 Azure IoT SDK (Java)。

我想创建一个在设备孪生的 JSON 中具有一些特定属性的新设备。我想在 Azure 门户中查看我的新设备,其中包含用于设备孪生的自定义 JSON。

ProvisioningTpmSample类中(链接 GitHub)。有这段代码:

try
{
    deviceClient = DeviceClient.createFromSecurityProvider(iotHubUri, deviceId, securityClientTPMEmulator, IotHubClientProtocol.MQTT);
    deviceClient.open();
    Message messageToSendFromDeviceToHub =  new Message("Whatever message you would like to send");

    System.out.println("Sending message from device to IoT Hub...");
    deviceClient.sendEventAsync(messageToSendFromDeviceToHub, new IotHubEventCallbackImpl(), null);
}

我找到了消息的 setProperty 方法。就像是

messageToSendFromDeviceToHub.setProperty("test", "test");

是否可以通过此setProperty方法定义设备孪生的所需必需属性?

非常感谢

4

0 回答 0