TT12-MCU/applications/demo.c
murmur 8cb31be86b 配置文件初步建立
看门狗不工作
待更新cfg中ini_puts和ini_gets函数为ini_putl和ini_getl
2023-06-01 10:23:08 +08:00

62 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;
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 * 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, 线);