I’m trying to use the test program ‘Azure-IoT_Central_ESP32.ino’ taken from the Azure-sdk-for_c Arduino version found in github to learn how Azure’s Device Provisioning Service (DPS) works. I’m using the Free Subscription or testing.
I believe I’ve setup everything on the Azure side correctly
A DPS resource
An IotHub linked to DPS
A DPS Enrollment group set for Symmetric Key attestation
The app itself compiles and runs fine but it always fails after an otherwise successful call to
azure_iot->config->mqtt_client_interface.mqtt_client_publish(azure_iot->mqtt_client_handle, &mqtt_message);
The mqtt_message_t topic and payload returned in the event generated by the above are as follows:
topic: $dps/registrations/res/401/?$rid=1{“errorCode”:401000,”trackingId”:”5c5e568d-91b0-48c4-9e6e-2418c0548d03″,”message”:”Unauthorized”,”timestampUtc”:”2024-07-29T04:04:56.5410409Z”}
payload: {“errorCode”:401000,”trackingId”:”5c5e568d-91b0-48c4-9e6e-2418c0548d03″,”message”:”Unauthorized”,”timestampUtc”:”2024-07-29T04:04:56.5410409Z”}
The only things I have changed in the original app are
#define DPS_ID_SCOPE "0ne00XXXXXXX" // (i.e. my test DPS scope)
#define IOT_CONFIG_DEVICE_ID "MyUniqueDeviceId1"
However, since I don’t have a device key (because the whole point is for DPS to setup the device for me?), I’m not sure what to set as
#define IOT_CONFIG_DEVICE_KEY
I’ve tried numerous things including the Enrollment Group Primary Key but the result is always the same.
I’m sure this will prove to be a really dumb problem but can somebody please help me understand and fix this?
FWIW, I’ve successfully written a test program to connect directly to and exchange data with an Azure IotHub so I’m not completely unfamiliar with the environment.
My (admittedly very limited) understanding of DPS is that since my DPS setup isn’t using X509 attestation, the DEVICE_KEY should be constructed internally by the SDK by mangling the Primary Key of the Enrollment Group and the unique IOT_CONFIG_DEVICE_ID for the new IotHub device I’m trying to create.
However, the iot_configs.h file in the example never explicitly asks me to provide that Primary Key so I’m very confused.
Thanks in advance,
John.
padzu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.