tls_os_timer_create(&mqtt.mqtt_demo_heartbeat_timer,
mqtt_demo_heart_timer,
NULL, 50, TRUE, (u8 *)"mqtt loop");
下面是源代码
tls_os_timer_start(mqtt.mqtt_demo_heartbeat_timer);
sprintf(str,"{\"current_temperature\":%.2f,\"current_humidity\":%.2f}",Temperature,Humidity);
app_mqtt_publish("data_report",str);
tls_os_time_delay(3000);
app_mqtt_disconnect(&mqtt); //断开连接
tls_os_timer_stop(mqtt.mqtt_demo_heartbeat_timer);
wm_printf("close mqtt_demo_loop\n");