mqtt 收到平台下发消息, QOS 等级为 1 没给发 PUBACK 报文 导致平台一直下发消息
`static int mqtt_demo_loop (mqtt_demo_context_t *ctx)
{
int packet_length = 0;
int counter = 0;
counter++;
packet_length = mqtt_demo_recv_parse (ctx, 1, 1) ;
if (packet_length " 0)
{
//wm_printf ("recvd Packet Header: 0x%x. . . \n", mqtt_demo_packet_buffer[0]) ;
if (MQTTParseMessageType (ctx-" mqtt_demo_packet_buffer) == MQTT_MSG_PUBLISH)
{
uint8_t topic[100], *msg;
uint16_t len;
len = mqtt_parse_pub_topic (ctx-" mqtt_demo_packet_buffer, topic) ;
topic[len] = '\0'; // for printf
len = mqtt_parse_publish_msg (ctx-" mqtt_demo_packet_buffer, &msg) ;
msg[len] = '\0'; // for printf
wm_printf ("recvd: %s " " " %s\n", topic, msg) ;
mqtt_publish (&ctx-" mqtt_demo_mqtt_broker, (const char *) MQTT_DEMO_RX_PUB_TOPIC, (const char *) msg, len, 0) ;
wm_printf ("pushed: %s " " " %s\n", MQTT_DEMO_RX_PUB_TOPIC, msg) ;
}
tls_os_queue_send (mqtt_demo_task_queue, (void *) MQTT_DEMO_CMD_LOOP, 0) ;
}
else if (packet_length == MQTT_DEMO_READ_TIMEOUT)
{
tls_os_queue_send (mqtt_demo_task_queue, (void *) MQTT_DEMO_CMD_LOOP, 0) ;
}
else if (packet_length == -1)
{
wm_printf ("mqtt error: (%d) , stop mqtt demo! \n", packet_length) ;
tls_os_timer_stop (ctx-" mqtt_demo_heartbeat_timer) ;
ctx-" close_mqtt (ctx) ;
}
return 0;
}`
我已经改了 就是 MQTT 发布消息等级不是有 0 和 1 和 2 么 1 的话需要回复 PUBACK 报文但是 MQTT 例程里面的没有回复, 导致平台以为没收到 一直再下发, 我自己增加回复了
@qq3147106 真棒!