bugfix fix shadow userdata

This commit is contained in:
ethan.du 2020-05-14 13:46:15 +08:00
parent df253cbf26
commit 971c6a1d96
2 changed files with 3 additions and 5 deletions

View File

@ -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; UIoT_Client *mqtt_client = (UIoT_Client *)ch_signal;
mqtt_client->event_handler.context = shadow_client;
shadow_client->product_sn = product_sn; shadow_client->product_sn = product_sn;
shadow_client->device_sn = device_sn; shadow_client->device_sn = device_sn;
shadow_client->mqtt = mqtt_client; shadow_client->mqtt = mqtt_client;

View File

@ -285,6 +285,7 @@ int uiot_shadow_subscribe_topic(UIoT_Shadow *pShadow, char *topicFilter, OnMessa
SubscribeParams subscribe_params = DEFAULT_SUB_PARAMS; SubscribeParams subscribe_params = DEFAULT_SUB_PARAMS;
subscribe_params.on_message_handler = on_message_handler; subscribe_params.on_message_handler = on_message_handler;
subscribe_params.user_data = pShadow;
subscribe_params.qos = QOS1; subscribe_params.qos = QOS1;
ret = IOT_MQTT_Subscribe(mqtt_client, topic_name, &subscribe_params); 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(pClient);
POINTER_VALID_CHECK_RTN(message); POINTER_VALID_CHECK_RTN(message);
UIoT_Client *mqtt_client = (UIoT_Client *)pClient; UIoT_Shadow *shadow_client = (UIoT_Shadow*)pUserdata;
UIoT_Shadow *shadow_client = (UIoT_Shadow*)mqtt_client->event_handler.context;
const char *topic = message->topic; const char *topic = message->topic;
size_t topic_len = message->topic_len; 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(pClient);
POINTER_VALID_CHECK_RTN(message); POINTER_VALID_CHECK_RTN(message);
UIoT_Client *mqtt_client = (UIoT_Client *)pClient; UIoT_Shadow *shadow_client = (UIoT_Shadow*)pUserdata;
UIoT_Shadow *shadow_client = (UIoT_Shadow*)mqtt_client->event_handler.context;
const char *topic = message->topic; const char *topic = message->topic;
size_t topic_len = message->topic_len; size_t topic_len = message->topic_len;