Azure Device Provisioning - Setting Device Twin property

130 views Asked by At

I want to use the device provisioning in Azure for my devices.

I'm using the Azure IoT SDK (Java).

I would like to create a new device that have some specific properties inside the JSON of the device twin. I want to see my new device in Azure portal with a custom JSON for the device twin.

In the ProvisioningTpmSample class (Link GitHub). There is this piece of code:

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);
}

I find the method setProperty for the Message. It's like

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

Is it possible to defined the desired and required properties of the device twin by this setProperty method?

Thanks a lot

0

There are 0 answers