I was able to connect to IOT Cental via Mqtt, and update a read-only property from device to server, and writable property from server to device.
I am wondering if it is possible to update a writable property from device to server, and how the payload would look like?
The IoT Plug and Play device developer guide described in details how to handle the telemetry, properties and commands in the device model. The simple case is when your model has only a default component.
The following example shows the major steps for updating a writeable property by device.
Creating a device template abba with a default component:
Device abba with this template and its view Pattern:
Simulated device abba using my Azure IoT Hub Tester:
Note, that the versions are after few testing properties and then resetting to null.
Updating both properties such as Reported (read-only property) and Desired (writable property) by device:
Showing the device twin on the device side:
IoT Central App view panel:
As you can see the above screen snippet, the read-only property shows immediately the value, but the writable property is showing a pending prompt text. In this point, the Desired property is waiting for accepting this value. Basically there are two ways how to make it, such as:
a. typing the value getting from the raw data or
b. using the REST PUT request call, see the following screen snippet:
IoT Central App view panel (updated):
Note, that the page must be refreshed manually, when the value has been accepted.
I do recommend to subscribe on the devicePropertyDesiredChange topic using the Data export features for receiving a notification on the changes, see an example of the message received in the Service Bus queue:
UPDATE:
In the case of using multiple components in your device model (at least one behind the default component), the following example shows how to update a writeable property in the component by device:
Creating a new version with a component abc:
New version of the Pattern view:
Simulated device abba2 sent the update for writable property Desired at the component abc:
IoT Central App shows a pending status:
Cloud backend service received a notification message in the queue:
Cloud backend service will sent an accepted request for this writable property, note, that the url address shows a path to the specific component:
IoT Central App shows a new accepted Desired value in the view Pattern at the ComponentA such as abc:
That's all. Using the above steps, any read-only and/or writable properties declared in the multiple components can be updated from the device side. Note, that the telemetry data outside of the default component are handling differently.