From 971c6a1d96533d4983dfe2c3b66848dbb1f83fde Mon Sep 17 00:00:00 2001 From: "ethan.du" Date: Thu, 14 May 2020 13:46:15 +0800 Subject: [PATCH] bugfix fix shadow userdata --- uiot/shadow/src/shadow_client.c | 1 - uiot/shadow/src/shadow_client_manager.c | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/uiot/shadow/src/shadow_client.c b/uiot/shadow/src/shadow_client.c index 492c865..be7bad4 100644 --- a/uiot/shadow/src/shadow_client.c +++ b/uiot/shadow/src/shadow_client.c @@ -45,7 +45,6 @@ void* IOT_Shadow_Construct(const char *product_sn, const char *device_sn, void * UIoT_Client *mqtt_client = (UIoT_Client *)ch_signal; - mqtt_client->event_handler.context = shadow_client; shadow_client->product_sn = product_sn; shadow_client->device_sn = device_sn; shadow_client->mqtt = mqtt_client; diff --git a/uiot/shadow/src/shadow_client_manager.c b/uiot/shadow/src/shadow_client_manager.c index e978d93..c7af3d5 100644 --- a/uiot/shadow/src/shadow_client_manager.c +++ b/uiot/shadow/src/shadow_client_manager.c @@ -285,6 +285,7 @@ int uiot_shadow_subscribe_topic(UIoT_Shadow *pShadow, char *topicFilter, OnMessa SubscribeParams subscribe_params = DEFAULT_SUB_PARAMS; subscribe_params.on_message_handler = on_message_handler; + subscribe_params.user_data = pShadow; subscribe_params.qos = QOS1; ret = IOT_MQTT_Subscribe(mqtt_client, topic_name, &subscribe_params); @@ -637,8 +638,7 @@ void topic_request_result_handler(void *pClient, MQTTMessage *message, void *pUs POINTER_VALID_CHECK_RTN(pClient); POINTER_VALID_CHECK_RTN(message); - UIoT_Client *mqtt_client = (UIoT_Client *)pClient; - UIoT_Shadow *shadow_client = (UIoT_Shadow*)mqtt_client->event_handler.context; + UIoT_Shadow *shadow_client = (UIoT_Shadow*)pUserdata; const char *topic = message->topic; size_t topic_len = message->topic_len; @@ -738,8 +738,7 @@ void topic_sync_handler(void *pClient, MQTTMessage *message, void *pUserdata) POINTER_VALID_CHECK_RTN(pClient); POINTER_VALID_CHECK_RTN(message); - UIoT_Client *mqtt_client = (UIoT_Client *)pClient; - UIoT_Shadow *shadow_client = (UIoT_Shadow*)mqtt_client->event_handler.context; + UIoT_Shadow *shadow_client = (UIoT_Shadow*)pUserdata; const char *topic = message->topic; size_t topic_len = message->topic_len;