Merge branch 'OpenAtomFoundation:master' into master
This commit is contained in:
@@ -65,7 +65,7 @@ void mqtt_demo_task(void)
|
|||||||
|
|
||||||
device_info_t dev_info;
|
device_info_t dev_info;
|
||||||
memset(&dev_info, 0, sizeof(device_info_t));
|
memset(&dev_info, 0, sizeof(device_info_t));
|
||||||
char str[16];
|
char str[32];
|
||||||
size_t mail_size;
|
size_t mail_size;
|
||||||
uint8_t report_error_count = 0;
|
uint8_t report_error_count = 0;
|
||||||
char client_token[10];
|
char client_token[10];
|
||||||
@@ -103,7 +103,7 @@ void mqtt_demo_task(void)
|
|||||||
tos_sleep_ms(5000);
|
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);
|
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) {
|
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));
|
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));
|
tos_mail_q_create(&mail_q, pm2d5_value_pool, 3, sizeof(pm2d5_data_u));
|
||||||
|
|
||||||
HAL_NVIC_DisableIRQ(USART2_IRQn);
|
HAL_NVIC_DisableIRQ(USART2_IRQn);
|
||||||
@@ -133,22 +133,22 @@ void mqtt_demo_task(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
/* 通过接收邮件来读取数据 */
|
||||||
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
||||||
tos_mail_q_pend(&mail_q, (uint8_t*)&pm2d5_value, &mail_size, TOS_TIME_FOREVER);
|
tos_mail_q_pend(&mail_q, (uint8_t*)&pm2d5_value, &mail_size, TOS_TIME_FOREVER);
|
||||||
HAL_NVIC_DisableIRQ(USART2_IRQn);
|
HAL_NVIC_DisableIRQ(USART2_IRQn);
|
||||||
|
|
||||||
//<EFBFBD>յ<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD>Ϣ
|
//收到之后打印信息
|
||||||
printf("\r\n\r\n\r\n");
|
printf("\r\n\r\n\r\n");
|
||||||
for (i = 0; i < 13; i++) {
|
for (i = 0; i < 13; i++) {
|
||||||
printf("data[%d]:%d ug/m3\r\n", i+1, pm2d5_value.data[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);
|
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));
|
generate_client_token(client_token, sizeof(client_token));
|
||||||
memset(payload, 0, 1024);
|
memset(payload, 0, 1024);
|
||||||
snprintf(payload, 1024, REPORT_DATA_TEMPLATE, client_token,
|
snprintf(payload, 1024, REPORT_DATA_TEMPLATE, client_token,
|
||||||
@@ -183,7 +183,7 @@ void application_entry(void *arg)
|
|||||||
{
|
{
|
||||||
char *str = "TencentOS-Tiny";
|
char *str = "TencentOS-Tiny";
|
||||||
|
|
||||||
/* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>OLED */
|
/* 初始化OLED */
|
||||||
|
|
||||||
mqtt_demo_task();
|
mqtt_demo_task();
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@@ -98,10 +98,10 @@ unsigned int salof_fifo_read(salof_fifo_t fifo, void *buff, unsigned int len, un
|
|||||||
{
|
{
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
salof_sem_pend(fifo->sem, timeout);
|
|
||||||
|
|
||||||
if((!fifo) || (!buff) || (!len))
|
if((!fifo) || (!buff) || (!len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
salof_sem_pend(fifo->sem, timeout);
|
||||||
|
|
||||||
len = FIFO_MIN(len, fifo->in - fifo->out);
|
len = FIFO_MIN(len, fifo->in - fifo->out);
|
||||||
|
|
||||||
|
@@ -386,7 +386,7 @@ static int air724_recv(int id, void *buf, size_t len)
|
|||||||
int air724_send(int id, const void *buf, size_t len)
|
int air724_send(int id, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
at_echo_t echo;
|
at_echo_t echo;
|
||||||
char expect_str[10];
|
char expect_str[24];
|
||||||
|
|
||||||
if (tos_at_global_lock_pend() != 0) {
|
if (tos_at_global_lock_pend() != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user