增加闹钟个数
This commit is contained in:
parent
c10be7faba
commit
2412d4fba7
@ -61,7 +61,11 @@ void alarm_sample(int argc, char *argv[])
|
||||
/* export msh cmd */
|
||||
MSH_CMD_EXPORT(alarm_sample,alarm sample);
|
||||
|
||||
|
||||
/**
|
||||
* 开窗回调
|
||||
* @param alarm
|
||||
* @param timestamp
|
||||
*/
|
||||
void poTT_callback(rt_alarm_t alarm, time_t timestamp)
|
||||
{
|
||||
LOG_I("power UP TT by RTC.");
|
||||
@ -69,6 +73,12 @@ void poTT_callback(rt_alarm_t alarm, time_t timestamp)
|
||||
setWindowMode();
|
||||
initTT();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关窗回调
|
||||
* @param alarm
|
||||
* @param timestamp
|
||||
*/
|
||||
void pdTT_callback(rt_alarm_t alarm, time_t timestamp)
|
||||
{
|
||||
LOG_I("power DOWN TT by RTC.");
|
||||
@ -76,6 +86,12 @@ void pdTT_callback(rt_alarm_t alarm, time_t timestamp)
|
||||
deInitTT();
|
||||
//预置开窗会更新多次尝试逻辑,未激活时会始终尝试
|
||||
}
|
||||
|
||||
/**
|
||||
* 每小时开窗回调
|
||||
* @param alarm
|
||||
* @param timestamp
|
||||
*/
|
||||
void poTT2_callback(rt_alarm_t alarm, time_t timestamp)
|
||||
{
|
||||
LOG_I("power UP TT by INTERVAL RTC");
|
||||
@ -84,7 +100,7 @@ void poTT2_callback(rt_alarm_t alarm, time_t timestamp)
|
||||
}
|
||||
//每个开窗设置对应两个rtc闹钟,一个上电一个下电
|
||||
//更新开窗设置前需要先清空闹钟设置。可改为调用rt_alarm_control()修改。
|
||||
static struct rt_alarm *alarm[4+1];//支持2组开窗共4个闹钟,加一个定时发送闹钟
|
||||
static struct rt_alarm *alarm[20];//支持2组开窗共4个闹钟,加一个定时发送闹钟
|
||||
#ifndef al
|
||||
void InitAlarm()
|
||||
{
|
||||
@ -177,10 +193,10 @@ void updateAlarm(uint8_t *t, size_t len)
|
||||
setup.wktime.tm_mon = p_tm.tm_mon;
|
||||
setup.wktime.tm_mday = p_tm.tm_mday;
|
||||
setup.wktime.tm_wday = p_tm.tm_wday;
|
||||
// setup.wktime.tm_hour = 1; //整点
|
||||
setup.wktime.tm_hour = 1; //整点
|
||||
setup.wktime.tm_min = 0; //p_tm.tm_min;
|
||||
setup.wktime.tm_sec = 0; //p_tm.tm_sec;
|
||||
|
||||
//
|
||||
setup.wktime.tm_hour = t[0]; //开窗1开启点
|
||||
setup.wktime.tm_min = t[1]; //开窗1开启点
|
||||
// if (RT_NULL != alarm[0])
|
||||
@ -218,7 +234,32 @@ void updateAlarm(uint8_t *t, size_t len)
|
||||
rt_alarm_control(alarm[3], RT_ALARM_CTRL_MODIFY, &setup);
|
||||
|
||||
|
||||
for (size_t var = 0; var < 4; var++) {
|
||||
//使用循环添加RTC
|
||||
// for (int var = 0; var < len; var+=4) {
|
||||
// setup.wktime.tm_hour = t[var+0]; //开窗1开启点
|
||||
// setup.wktime.tm_min = t[var+1]; //开窗1开启点
|
||||
// int index = var/2;
|
||||
//
|
||||
// if (alarm[index])
|
||||
// {
|
||||
// rt_alarm_control(alarm[index], RT_ALARM_CTRL_MODIFY, &setup);
|
||||
// }
|
||||
// else {
|
||||
// alarm[index] = rt_alarm_create(poTT_callback, &setup);
|
||||
// }
|
||||
//
|
||||
// setup.wktime.tm_hour = t[var+2]; //开窗1闭合点
|
||||
// setup.wktime.tm_min = t[var+3]; //开窗1开启点
|
||||
// if (alarm[index+1])
|
||||
// {
|
||||
// rt_alarm_control(alarm[index+1], RT_ALARM_CTRL_MODIFY, &setup);
|
||||
// }
|
||||
// else {
|
||||
// alarm[index+1] = rt_alarm_create(pdTT_callback, &setup);
|
||||
// }
|
||||
// }
|
||||
|
||||
for (size_t var = 0; var < len/2; var++) {
|
||||
if (alarm[var] != RT_NULL) {
|
||||
rt_alarm_start(alarm[var]);
|
||||
// LOG_D("alarm %d started.",var+1);
|
||||
|
@ -108,6 +108,7 @@ void initFiles()
|
||||
"locAlert=1;\n"
|
||||
"# 定时上报位置信息间隔(M)\n"
|
||||
"locRepInterval=1\n"
|
||||
"isMaWin=-1\n"
|
||||
"[stats]\n"
|
||||
"# 继电器开关次数,影响继电器寿命(<10W次)\n"
|
||||
"swCnt=12\n"
|
||||
@ -180,10 +181,10 @@ static void initCfg(void)
|
||||
scfg.maxSizePerFile = get_cfg("maxSizePerFile");
|
||||
scfg.locRepInterval = get_cfg("locRepInterval");
|
||||
|
||||
char str[20];
|
||||
char str[100];
|
||||
get_cfgs("openWindowTime", str);
|
||||
size_t len = str2Byte(str, 3, 10, scfg.openWindowTime);
|
||||
// LOG_HEX("win",16,scfg.openWindowTime,8);
|
||||
// LOG_HEX("win",16,scfg.openWindowTime,len);
|
||||
updateAlarm(scfg.openWindowTime, len);
|
||||
|
||||
LOG_D("cfg updated.");
|
||||
|
@ -124,4 +124,4 @@ void updateLogFileBackend()
|
||||
}
|
||||
|
||||
MSH_CMD_EXPORT(sys_log_file_backend_init,log2file);
|
||||
INIT_APP_EXPORT(sys_log_file_backend_init);
|
||||
//INIT_APP_EXPORT(sys_log_file_backend_init);
|
||||
|
@ -50,7 +50,7 @@ typedef struct
|
||||
uint8_t minTTPeriCnt;
|
||||
uint8_t minTTsinal;
|
||||
uint8_t timeout;
|
||||
uint8_t openWindowTime[8];
|
||||
uint8_t openWindowTime[20];
|
||||
uint16_t maxSizePerFile;
|
||||
uint8_t commMode;
|
||||
uint8_t selfDesSW;
|
||||
|
Loading…
Reference in New Issue
Block a user