Fixed bug in mqtt_iot_explorer_tc_pm25_oled.c
This commit is contained in:
@@ -45,7 +45,7 @@ void mqtt_demo_task(void)
|
||||
|
||||
|
||||
|
||||
/* OLED<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>־ */
|
||||
/* OLED显示日志 */
|
||||
OLED_ShowString(0, 2, (uint8_t*)"connecting...", 16);
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ void mqtt_demo_task(void)
|
||||
printf("MQTT: %s\n", state == MQTT_STATE_CONNECTED ? "CONNECTED" : "DISCONNECTED");
|
||||
}
|
||||
|
||||
/* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>topic */
|
||||
/* 开始订阅topic */
|
||||
size = snprintf(report_reply_topic_name, TOPIC_NAME_MAX_SIZE, "$thing/down/property/%s/%s", product_id, device_name);
|
||||
|
||||
if (size < 0 || size > sizeof(report_reply_topic_name) - 1) {
|
||||
@@ -87,14 +87,14 @@ void mqtt_demo_task(void)
|
||||
printf("module mqtt sub success\n");
|
||||
}
|
||||
|
||||
memset(report_topic_name, sizeof(report_topic_name), 0);
|
||||
memset(report_topic_name, 0, sizeof(report_topic_name));
|
||||
size = snprintf(report_topic_name, TOPIC_NAME_MAX_SIZE, "$thing/up/property/%s/%s", product_id, device_name);
|
||||
|
||||
if (size < 0 || size > sizeof(report_topic_name) - 1) {
|
||||
printf("pub topic content length not enough! content size:%d buf size:%d", size, (int)sizeof(report_topic_name));
|
||||
}
|
||||
|
||||
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
/* 创建邮箱 */
|
||||
tos_mail_q_create(&mail_q, pm2d5_value_pool, 3, sizeof(pm2d5_data_u));
|
||||
|
||||
HAL_NVIC_DisableIRQ(USART3_4_IRQn);
|
||||
@@ -105,18 +105,18 @@ void mqtt_demo_task(void)
|
||||
}
|
||||
|
||||
while (1) {
|
||||
/* ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
/* 通过接收邮件来读取数据 */
|
||||
HAL_NVIC_EnableIRQ(USART3_4_IRQn);
|
||||
tos_mail_q_pend(&mail_q, (uint8_t*)&pm2d5_value, &mail_size, TOS_TIME_FOREVER);
|
||||
HAL_NVIC_DisableIRQ(USART3_4_IRQn);
|
||||
|
||||
//<EFBFBD>յ<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD>Ϣ
|
||||
//收到之后打印信息
|
||||
printf("\r\n\r\n\r\n");
|
||||
for (i = 0; i < 13; i++) {
|
||||
printf("data[%d]:%d ug/m3\r\n", i+1, pm2d5_value.data[i]);
|
||||
}
|
||||
|
||||
//<EFBFBD><EFBFBD>ʾPM2.5<EFBFBD><EFBFBD>ֵ
|
||||
//显示PM2.5的值
|
||||
OLED_Clear();
|
||||
sprintf(str, "PM1.0:%4d ug/m3", pm2d5_value.pm2d5_data.data1);
|
||||
OLED_ShowString(0,0,(uint8_t*)str,16);
|
||||
@@ -124,7 +124,7 @@ void mqtt_demo_task(void)
|
||||
OLED_ShowString(0,2,(uint8_t*)str,16);
|
||||
|
||||
|
||||
/* <EFBFBD>ϱ<EFBFBD>ֵ */
|
||||
/* 上报值 */
|
||||
memset(payload, 0, sizeof(payload));
|
||||
snprintf(payload, sizeof(payload), REPORT_DATA_TEMPLATE, pm2d5_value.pm2d5_data.data2);
|
||||
|
||||
@@ -144,7 +144,7 @@ void application_entry(void *arg)
|
||||
{
|
||||
char *str = "TencentOS-tiny";
|
||||
|
||||
/* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>OLED */
|
||||
/* 初始化OLED */
|
||||
OLED_Init();
|
||||
OLED_Clear();
|
||||
OLED_ShowString(0, 0, (uint8_t*)str, 16);
|
||||
|
Reference in New Issue
Block a user