TT12-MCU/applications/demo.c
murmur 5af0888b3b demo.c 添加线程接收用例
添加 ttTR.c ,基本完成发送功能
2023-05-30 16:53:31 +08:00

55 lines
1.3 KiB
C

/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-05-18 murmur the first version
*/
#include <rtthread.h>
#define LOG_TAG "cfg"
#define LOG_LVL LOG_LVL_DBG
#include <ulog.h>
#include <cJSON.h>
#include <dfs_file.h>
#include <cfg.h>
void getcfg(void)
{
extern struct rt_messagequeue update_cfg;
CFG_MSG msg;
while (1)
{
rt_memset(&msg, 0, sizeof(msg));
/* 从消息队列中读取消息*/
rt_err_t result = rt_mq_recv(&update_cfg, &msg, sizeof(msg), RT_WAITING_NO);
if (result == RT_EOK)
{
LOG_I("updatecfg:%10s -->%s", msg.key, msg.value);
}
rt_thread_delay(100);
}
}
void mpcfg()
{
/* 创建线程 */
rt_thread_t thread = rt_thread_create("getcfg", getcfg, RT_NULL, 1024 * 1, 20, 10);
/* 创建成功则启动线程 */
if (thread != RT_NULL)
{
rt_thread_startup(thread);
// rt_kprintf("done");
}
else
{
LOG_E("thread 'pmsg' create failure.");
return RT_ERROR;
}
}
/* 导出到自动初始化 */
//INIT_COMPONENT_EXPORT(mpcfg);
MSH_CMD_EXPORT(mpcfg, 线);