@@ -64,7 +64,7 @@ static int _publish_operation_to_cloud(Qcloud_IoT_Shadow *pShadow, Method method
6464
6565static int _add_request_to_list (Qcloud_IoT_Shadow * pShadow , const char * pClientToken , RequestParams * pParams );
6666
67- static int _unsubscribe_operation_result_to_cloud (void * pClient );
67+ static int _unsubscribe_operation_result_to_cloud (Qcloud_IoT_Shadow * pShadow );
6868
6969static void _traverse_list (Qcloud_IoT_Shadow * pShadow , List * list , const char * pClientToken , const char * pType , TraverseHandle traverseHandle );
7070
@@ -110,7 +110,7 @@ void qcloud_iot_shadow_reset(void *pClient)
110110 list_destroy (shadow_client -> inner_data .property_handle_list );
111111 }
112112
113- _unsubscribe_operation_result_to_cloud (shadow_client -> mqtt );
113+ _unsubscribe_operation_result_to_cloud (shadow_client );
114114
115115 if (shadow_client -> inner_data .request_list ) {
116116 list_destroy (shadow_client -> inner_data .request_list );
@@ -403,22 +403,17 @@ static int _set_shadow_json_type(char *pJsonDoc, size_t sizeOfBuffer, Method met
403403/**
404404 * @brief unsubsribe topic: $shadow/operation/result/{ProductId}/{DeviceName}
405405 */
406- static int _unsubscribe_operation_result_to_cloud (void * pClient )
406+ static int _unsubscribe_operation_result_to_cloud (Qcloud_IoT_Shadow * pShadow )
407407{
408408 IOT_FUNC_ENTRY ;
409409 int rc = QCLOUD_RET_SUCCESS ;
410410
411- char operation_result_topic [MAX_SIZE_OF_CLOUD_TOPIC ] = {0 };
412- int size = HAL_Snprintf (operation_result_topic , MAX_SIZE_OF_CLOUD_TOPIC , "$shadow/operation/result/%s/%s" , iot_device_info_get ()-> product_id , iot_device_info_get ()-> device_name );
413-
414- if (size < 0 || size > MAX_SIZE_OF_CLOUD_TOPIC - 1 ) {
415- Log_e ("buf size < topic length!" );
416- IOT_FUNC_EXIT_RC (QCLOUD_ERR_FAILURE );
417- }
418-
419- IOT_MQTT_Unsubscribe (pClient , operation_result_topic );
411+ if (pShadow -> inner_data .result_topic == NULL )
412+ IOT_FUNC_EXIT_RC (rc );
413+
414+ rc = IOT_MQTT_Unsubscribe (pShadow -> mqtt , pShadow -> inner_data .result_topic );
420415 if (rc < 0 ) {
421- Log_e ("unsubscribe topic: %s failed: %d." , operation_result_topic , rc );
416+ Log_e ("unsubscribe topic: %s failed: %d." , pShadow -> inner_data . result_topic , rc );
422417 }
423418
424419 IOT_FUNC_EXIT_RC (rc );
0 commit comments