TT12-MCU/applications/demo.c
murmur e35670b6a9 添加demo板兼容逻辑
添加规则处理函数(未测试)
添加总usrcfg.h文件
2023-06-02 10:23:26 +08:00

63 lines
1.6 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 "demo"
#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;
extern struct rt_event update_cfg;
CFG_MSG msg;
pwTT_thread_entry("1");
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_uint32_t e;
rt_err_t result = rt_event_recv(&update_cfg, CFGCHANGEED|COMPRESSTYPE, RT_EVENT_FLAG_OR|RT_EVENT_FLAG_CLEAR, RT_WAITING_NO, &e);
if (result == RT_EOK)
{
LOG_I("updatecfg");
}
rt_thread_delay(100);
}
}
void mpcfg()
{
/* 创建线程 */
rt_thread_t thread = rt_thread_create("getcfg", getcfg, RT_NULL, 1024 * 2, 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, 线);