Fixed bug in mqtt_iot_explorer_tc_ch20_oled.c

This commit is contained in:
David Lin
2021-01-01 11:13:36 +08:00
committed by GitHub
parent 1f510c6da6
commit da79f4318f

View File

@@ -47,7 +47,7 @@ void mqtt_demo_task(void)
char ch20_ppm_str[20];
/* OLED<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>־ */
/* OLED显示日志 */
OLED_ShowString(0, 2, (uint8_t*)"connecting...", 16);
/**
@@ -77,7 +77,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) {
@@ -89,14 +89,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, ch20_value_pool, 3, sizeof(ch20_data_t));
HAL_NVIC_DisableIRQ(USART3_4_IRQn);
@@ -107,20 +107,20 @@ 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*)&ch20_value, &mail_size, TOS_TIME_FOREVER);
HAL_NVIC_DisableIRQ(USART3_4_IRQn);
/* <EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD>Ϣ */
/* 接收到之后打印信息 */
ch20_ppm_value = ch20_value.data / 1000.0;
printf("ch20 value: %.3f\r\n", ch20_ppm_value);
/* OLED<EFBFBD><EFBFBD>ʾֵ */
/* OLED显示值 */
sprintf(ch20_ppm_str, "%.3f ppm(mg/m3)", ch20_ppm_value);
OLED_ShowString(0, 2, (uint8_t*)ch20_ppm_str, 16);
/* <EFBFBD>ϱ<EFBFBD>ֵ */
/* 上报值 */
memset(payload, 0, sizeof(payload));
snprintf(payload, sizeof(payload), REPORT_DATA_TEMPLATE, ch20_ppm_value);
@@ -143,7 +143,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);