Update mqtt_iot_explorer_esp8266.c

This commit is contained in:
7YZ7
2023-04-23 13:41:24 +08:00
committed by GitHub
parent 0cef33e152
commit 146d03916e

View File

@@ -65,7 +65,7 @@ void mqtt_demo_task(void)
device_info_t dev_info;
memset(&dev_info, 0, sizeof(device_info_t));
char str[16];
char str[32];
size_t mail_size;
uint8_t report_error_count = 0;
char client_token[10];
@@ -103,7 +103,7 @@ void mqtt_demo_task(void)
tos_sleep_ms(5000);
}
/* <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) {
@@ -122,7 +122,7 @@ void mqtt_demo_task(void)
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(USART2_IRQn);
@@ -133,22 +133,22 @@ 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(USART2_IRQn);
tos_mail_q_pend(&mail_q, (uint8_t*)&pm2d5_value, &mail_size, TOS_TIME_FOREVER);
HAL_NVIC_DisableIRQ(USART2_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的值 */
sprintf(str, "PM2.5:%4d ug/m3", pm2d5_value.pm2d5_data.data2);
OLED_ShowString(0,0,(uint8_t*)str,16);
OLED_ShowString(0,0,(uint8_t*)str,32);
/* <EFBFBD>ϱ<EFBFBD>ֵ */
/* 上报值 */
generate_client_token(client_token, sizeof(client_token));
memset(payload, 0, 1024);
snprintf(payload, 1024, REPORT_DATA_TEMPLATE, client_token,
@@ -183,7 +183,7 @@ void application_entry(void *arg)
{
char *str = "TencentOS-Tiny";
/* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>OLED */
/* 初始化OLED */
mqtt_demo_task();
while (1) {