@@ -64,7 +64,7 @@ static int _publish_operation_to_cloud(Qcloud_IoT_Shadow *pShadow, Method method
64
64
65
65
static int _add_request_to_list (Qcloud_IoT_Shadow * pShadow , const char * pClientToken , RequestParams * pParams );
66
66
67
- static int _unsubscribe_operation_result_to_cloud (void * pClient );
67
+ static int _unsubscribe_operation_result_to_cloud (Qcloud_IoT_Shadow * pShadow );
68
68
69
69
static void _traverse_list (Qcloud_IoT_Shadow * pShadow , List * list , const char * pClientToken , const char * pType , TraverseHandle traverseHandle );
70
70
@@ -110,7 +110,7 @@ void qcloud_iot_shadow_reset(void *pClient)
110
110
list_destroy (shadow_client -> inner_data .property_handle_list );
111
111
}
112
112
113
- _unsubscribe_operation_result_to_cloud (shadow_client -> mqtt );
113
+ _unsubscribe_operation_result_to_cloud (shadow_client );
114
114
115
115
if (shadow_client -> inner_data .request_list ) {
116
116
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
403
403
/**
404
404
* @brief unsubsribe topic: $shadow/operation/result/{ProductId}/{DeviceName}
405
405
*/
406
- static int _unsubscribe_operation_result_to_cloud (void * pClient )
406
+ static int _unsubscribe_operation_result_to_cloud (Qcloud_IoT_Shadow * pShadow )
407
407
{
408
408
IOT_FUNC_ENTRY ;
409
409
int rc = QCLOUD_RET_SUCCESS ;
410
410
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 );
420
415
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 );
422
417
}
423
418
424
419
IOT_FUNC_EXIT_RC (rc );
0 commit comments