Skip to content

Commit 5558c5d

Browse files
committed
修复MQTT订阅采用动态存储topic name方式之后,在自动重连resubscribe时出现的bug
1 parent 3a68b57 commit 5558c5d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/mqtt/src/mqtt_client_subscribe.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ int qcloud_iot_mqtt_resubscribe(Qcloud_IoT_Client *pClient) {
188188
uint32_t len = 0;
189189
uint32_t itr = 0;
190190
char *topic = NULL;
191+
SubscribeParams temp_param;
191192
uint16_t packet_id = 0;
192193

193194
ListNode *node = NULL;
@@ -205,7 +206,17 @@ int qcloud_iot_mqtt_resubscribe(Qcloud_IoT_Client *pClient) {
205206
if (topic == NULL) {
206207
continue;
207208
}
209+
temp_param.on_message_handler = pClient->sub_handles[itr].message_handler;
210+
temp_param.qos = pClient->sub_handles[itr].qos;
211+
temp_param.user_data = pClient->sub_handles[itr].message_handler_data;
208212

213+
rc = qcloud_iot_mqtt_subscribe(pClient, topic, &temp_param);
214+
if (rc < 0) {
215+
Log_e("resubscribe failed %d, topic: %s", rc, topic);
216+
IOT_FUNC_EXIT_RC(rc);
217+
}
218+
219+
#if 0
209220
InitTimer(&timer);
210221
countdown_ms(&timer, pClient->command_timeout_ms);
211222

@@ -244,6 +255,7 @@ int qcloud_iot_mqtt_resubscribe(Qcloud_IoT_Client *pClient) {
244255
}
245256

246257
HAL_MutexUnlock(pClient->lock_write_buf);
258+
#endif
247259
}
248260

249261
IOT_FUNC_EXIT_RC(QCLOUD_ERR_SUCCESS);

0 commit comments

Comments
 (0)