44
44
#define SAMPLE_COMMAND_SUCCESS_STATUS (200)
45
45
#define SAMPLE_COMMAND_ERROR_STATUS (500)
46
46
47
- #define SAMPLE_PNP_MODEL_ID "dtmi:com:example:Thermostat;3 "
47
+ #define SAMPLE_PNP_MODEL_ID "dtmi:com:example:Thermostat;4 "
48
48
#define SAMPLE_PNP_DPS_PAYLOAD "{\"modelId\":\"" SAMPLE_PNP_MODEL_ID "\"}"
49
49
50
+ /* Credential Information on DataFlash */
51
+ #ifndef ENABLE_DPS_SAMPLE
50
52
extern volatile const uint8_t df_host_name ;
51
53
extern volatile const uint8_t df_device_id ;
54
+
55
+ #else /* !ENABLE_DPS_SAMPLE */
56
+
57
+ extern volatile const uint8_t df_endpoint ;
58
+ extern volatile const uint8_t df_id_scope ;
59
+ extern volatile const uint8_t df_registration_id ;
60
+ #endif /* ENABLE_DPS_SAMPLE */
52
61
extern volatile const uint8_t df_device_symmetric_key ;
62
+ extern volatile const uint8_t df_module_id ;
63
+ #if (USE_DEVICE_CERTIFICATE == 1 )
64
+ extern volatile const uint8_t df_device_cert ;
65
+ extern volatile const uint8_t df_device_private_key ;
66
+ #endif /* USE_DEVICE_CERTIFICATE */
53
67
54
68
/* Generally, IoTHub Client and DPS Client do not run at the same time, user can use union as below to
55
69
share the memory between IoTHub Client and DPS Client.
@@ -389,6 +403,9 @@ UCHAR *iothub_device_id = (UCHAR *)&df_device_id;
389
403
UINT iothub_hostname_length = strlen ( (const char * )& df_host_name );
390
404
UINT iothub_device_id_length = strlen ( (const char * )& df_device_id );
391
405
#endif /* ENABLE_DPS_SAMPLE */
406
+ UCHAR * iothub_module_id = (UCHAR * )& df_module_id ;
407
+ UINT iothub_module_id_length = strlen ( (const char * )& df_module_id );
408
+
392
409
393
410
#ifdef ENABLE_DPS_SAMPLE
394
411
@@ -408,7 +425,7 @@ UINT iothub_device_id_length = strlen( (const char *)&df_device_id );
408
425
if ((status = nx_azure_iot_hub_client_initialize (iothub_client_ptr , & nx_azure_iot ,
409
426
iothub_hostname , iothub_hostname_length ,
410
427
iothub_device_id , iothub_device_id_length ,
411
- ( const UCHAR * ) MODULE_ID , sizeof ( MODULE_ID ) - 1 ,
428
+ iothub_module_id , iothub_module_id_length ,
412
429
_nx_azure_iot_tls_supported_crypto ,
413
430
_nx_azure_iot_tls_supported_crypto_size ,
414
431
_nx_azure_iot_tls_ciphersuite_map ,
@@ -842,13 +859,22 @@ static UINT sample_dps_entry(NX_AZURE_IOT_PROVISIONING_CLIENT *prov_client_ptr,
842
859
{
843
860
UINT status ;
844
861
862
+ UCHAR * iothub_endpoint = (UCHAR * )& df_endpoint ;
863
+ UCHAR * iothub_id_scope = (UCHAR * )& df_id_scope ;
864
+ UCHAR * iothub_registration_id = (UCHAR * )& df_registration_id ;
865
+
866
+ UINT iothub_endpoint_len = strlen ( (const char * )& df_endpoint );
867
+ UINT iothub_id_scope_id_len = strlen ( (const char * )& df_id_scope );
868
+ UINT iothub_registration_id_len = strlen ( (const char * )& df_registration_id );
869
+
870
+
845
871
LOG_TERMINAL ("Start Provisioning Client...\r\n" );
846
872
847
873
/* Initialize IoT provisioning client. */
848
874
if ((status = nx_azure_iot_provisioning_client_initialize (prov_client_ptr , & nx_azure_iot ,
849
- ( UCHAR * ) ENDPOINT , sizeof ( ENDPOINT ) - 1 ,
850
- ( UCHAR * ) ID_SCOPE , sizeof ( ID_SCOPE ) - 1 ,
851
- ( UCHAR * ) REGISTRATION_ID , sizeof ( REGISTRATION_ID ) - 1 ,
875
+ iothub_endpoint , iothub_endpoint_len ,
876
+ iothub_id_scope , iothub_id_scope_id_len ,
877
+ iothub_registration_id , iothub_registration_id_len ,
852
878
_nx_azure_iot_tls_supported_crypto ,
853
879
_nx_azure_iot_tls_supported_crypto_size ,
854
880
_nx_azure_iot_tls_ciphersuite_map ,
@@ -892,8 +918,8 @@ UINT status;
892
918
#else
893
919
894
920
/* Set symmetric key. */
895
- else if ((status = nx_azure_iot_provisioning_client_symmetric_key_set (prov_client_ptr , (UCHAR * )DEVICE_SYMMETRIC_KEY ,
896
- sizeof ( DEVICE_SYMMETRIC_KEY ) - 1 )))
921
+ else if ((status = nx_azure_iot_provisioning_client_symmetric_key_set (prov_client_ptr , (UCHAR * )& df_device_symmetric_key ,
922
+ strlen ( ( const char * ) & df_device_symmetric_key ) )))
897
923
{
898
924
LOG_TERMINAL ("Failed on nx_azure_iot_hub_client_symmetric_key_set!: error code = 0x%08x\r\n" , status );
899
925
}
0 commit comments