@@ -216,6 +216,18 @@ static UINT iot_hub_initialize(AZURE_IOT_NX_CONTEXT* nx_context)
216216 printf ("Error: device twin desired property callback set (0x%08x)\r\n" , status );
217217 }
218218
219+ // Register the pnp components for receiving
220+ for (int i = 0 ; i < nx_context -> azure_iot_component_count ; ++ i )
221+ {
222+ if ((status = nx_azure_iot_hub_client_component_add (& nx_context -> iothub_client ,
223+ (UCHAR * )nx_context -> azure_iot_components [i ],
224+ strlen (nx_context -> azure_iot_components [i ]))))
225+ {
226+ printf ("ERROR: nx_azure_iot_hub_client_component_add failed (0x%08x)\r\n" , status );
227+ break ;
228+ }
229+ }
230+ 219231 if (status != NX_AZURE_IOT_SUCCESS )
220232 {
221233 nx_azure_iot_hub_client_deinitialize (& nx_context -> iothub_client );
@@ -480,13 +492,7 @@ static UINT process_properties_shared(AZURE_IOT_NX_CONTEXT* nx_context,
480492 return status ;
481493 }
482494
483- if ((status = nx_azure_iot_json_reader_init (& json_reader , packet_ptr )))
484- {
485- printf ("Init json reader failed!: error code = 0x%08x\r\n" , status );
486- nx_packet_release (packet_ptr );
487- return status ;
488- }
489- 495+ // reinitialize the json reader after reading the version to reset
490496 if ((status = nx_azure_iot_json_reader_init (& json_reader , packet_ptr )))
491497 {
492498 printf ("Error: failed to initialize json reader (0x%08x)\r\n" , status );
@@ -937,6 +943,23 @@ UINT azure_iot_nx_client_register_timer_callback(
937943 return NX_SUCCESS ;
938944}
939945
946+ UINT azure_iot_nx_client_add_component (AZURE_IOT_NX_CONTEXT * nx_context , CHAR * component_name )
947+ {
948+ if (nx_context == NULL || component_name == NULL )
949+ {
950+ return NX_PTR_ERROR ;
951+ }
952+ 953+ if (nx_context -> azure_iot_component_count >= NX_AZURE_IOT_HUB_CLIENT_MAX_COMPONENT_LIST )
954+ {
955+ return NX_AZURE_IOT_INSUFFICIENT_BUFFER_SPACE ;
956+ }
957+ 958+ nx_context -> azure_iot_components [nx_context -> azure_iot_component_count ] = component_name ;
959+ nx_context -> azure_iot_component_count ++ ;
960+ return NX_SUCCESS ;
961+ }
962+ 940963UINT azure_iot_nx_client_sas_set (AZURE_IOT_NX_CONTEXT * context , CHAR * device_sas_key )
941964{
942965 if (device_sas_key [0 ] == 0 )
0 commit comments