Hello
We have an issue using the Azure DPS in the azure_iot_hub demo.
What we did so far
- Setup the Azure IoT Hub Device Provisioning Service (DPS) on our Azure portal
- Linked this DPS to our (existing) IoT Hub
- defined enrollments
(everything is based on X.509 certificates)
- we configured the DPS settings in prj.conf
CONFIG_AZURE_IOT_HUB_DPS=y CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE="xxxxxxxxxxx" CONFIG_AZURE_IOT_HUB_DPS_REG_ID="myDpsDevice" CONFIG_AZURE_IOT_HUB_DPS_HOSTNAME="Xyz.azure-devices-provisioning.net"
* the "xxxxxxxxxxx" is a place holder for the real ID Scope provided by our DPS on Azure.
the same with the "Xyz" preabmle for the host name
What happened
The first time run the sample, DPS worked and our device was connected to our IoT hub. From now on our device directly connects to the hub after restarting the sample.
(But the initial DPS only worked when giving our device the device name of the already existing "old" device ("xyzDevice01") on our IoT Hub. Our understanding was, that our device should get a "new" device name from the IoT hub).
Our issue
To be able to continue with our tests, we have to be able to reset the DPS connection to our hub.
We found that there is a function called azure_iot_hub_dps_reset() to do this job.
We placed this function just before calling azure_iot_hub_dps_init().
The azure_iot_hub_dps_reset function runs without error but later calling azure_iot_hub_dps_start() gives err -120 as result ("Already assigned to an IoT hub, skipping DPS").
Our first analysis
azure_iot_hub_dps_reset() calls azure_iot_hub_dps_hostname_delete() and azure_iot_hub_dps_device_id_delete().
As far as we understand, these functions should delete DPS related entries in the persistent memory. But they do not.
Both (settings_delete()) function calls are returning with err -2 ("No hostname/device ID was stored").
But the azure_iot_hub_dps_init() function loads the persistent data again back to the local dps_reg_ctx structure, even if settings_delete() returned with err -2. This latert results in err -120.
What are we doing wrong? How can we reset an existing DPS "binding" to our Azure IoT hub?
Regards
Michael