Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Add provPayload at DevkitDPSClientStart() #1027

Open
wants to merge 1 commit into
base: public-preview
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions AZ3166/src/libraries/AzureIoT/src/DevkitDPSClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ char* DiceInit(char* udsString)

bool __attribute__((section(".riot_fw"))) DevkitDPSClientStart(const char* global_prov_uri,
const char* id_scope, const char* registration_id, char* udsString,
const char* proxy_address, int proxy_port)
const char* proxy_address, int proxy_port, const char* provPayload)
{
bool result = true;

Expand Down Expand Up @@ -251,17 +251,17 @@ bool __attribute__((section(".riot_fw"))) DevkitDPSClientStart(const char* globa
LogError("Failed to initialize the platform.");
result = false;
}
else if (g_auth_type == DPS_AUTH_SYMMETRIC_KEY && prov_dev_security_init(SECURE_DEVICE_TYPE_SYMMETRIC_KEY) != 0)
{
LogError("Failed to initialize the platform.");
result = false;
}
else if (g_auth_type == DPS_AUTH_SYMMETRIC_KEY && prov_dev_set_symmetric_key_info(registration_id, udsString) != 0)
{
LogError("Failed to initialize the platform.");
result = false;
}
else
else if (g_auth_type == DPS_AUTH_SYMMETRIC_KEY && prov_dev_security_init(SECURE_DEVICE_TYPE_SYMMETRIC_KEY) != 0)
{
LogError("Failed to initialize the platform.");
result = false;
}
else if (g_auth_type == DPS_AUTH_SYMMETRIC_KEY && prov_dev_set_symmetric_key_info(registration_id, udsString) != 0)
{
LogError("Failed to initialize the platform.");
result = false;
}
else
{
memset(&user_ctx, 0, sizeof(CLIENT_SAMPLE_INFO));

Expand Down Expand Up @@ -291,12 +291,18 @@ bool __attribute__((section(".riot_fw"))) DevkitDPSClientStart(const char* globa
}

(void)Prov_Device_LL_SetOption(handle, "logtrace", &g_trace_on);
if (Prov_Device_LL_SetOption(handle, "TrustedCerts", certificates) != PROV_DEVICE_RESULT_OK)

if (provPayload != NULL && Prov_Device_LL_Set_Provisioning_Payload(handle, provPayload) != PROV_DEVICE_RESULT_OK)
{
LogError("Failed to set option \"Provisioning Payload\"");
result = false;
}
else if (Prov_Device_LL_SetOption(handle, "TrustedCerts", certificates) != PROV_DEVICE_RESULT_OK)
{
LogError("Failed to set option \"TrustedCerts\"");
result = false;
}
else if (Prov_Device_LL_Register_Device(handle, register_device_callback, &user_ctx, registation_status_callback, &user_ctx) != PROV_DEVICE_RESULT_OK)
else if (Prov_Device_LL_Register_Device(handle, register_device_callback, &user_ctx, registation_status_callback, &user_ctx) != PROV_DEVICE_RESULT_OK)
{
LogError("failed calling Prov_Device_LL_Register_Device");
result = false;
Expand Down
2 changes: 1 addition & 1 deletion AZ3166/src/libraries/AzureIoT/src/DevkitDPSClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void DevkitDPSSetLogTrace(bool ison);
void DevkitDPSSetAuthType(DPS_AUTH_TYPE auth_type);

bool DevkitDPSClientStart(const char* dps_uri, const char* dps_scope_id, const char* registration_id = NULL,
char* udsString = NULL, const char* proxy_address = NULL, int proxy_port = 0);
char* udsString = NULL, const char* proxy_address = NULL, int proxy_port = 0, const char* provPayload = NULL);

char* DevkitDPSGetIoTHubURI(void);
char* DevkitDPSGetDeviceID(void);
Expand Down