逻辑判断中提升手动开窗优先级

闹钟默认不开
This commit is contained in:
CSSC-WORK\murmur 2023-09-15 16:36:52 +08:00
parent e5e78dbaec
commit e903623c58
3 changed files with 20 additions and 11 deletions

View File

@ -239,7 +239,7 @@ void addAlarm(uint8_t *din, rt_alarm_callback_t callback)
if (RT_NULL != alarm)
{
rt_alarm_start(alarm);
// rt_alarm_start(alarm);//默认不启动
// LOG_D("alarm started.");
}
else {

View File

@ -191,6 +191,7 @@ static void initCfg(void)
size_t len = str2Byte(str, 3, 10, scfg.openWindowTime);
// LOG_HEX("win",16,scfg.openWindowTime,len);
updateAlarm(scfg.openWindowTime, len);
startAlarm();
LOG_D("cfg updated.");
}
@ -260,7 +261,7 @@ void sysInit(void)
sysSemInit();
initCfg();
checkManualWindow();
if (isInWindowZone() || isManualWindow()) {//开机检查是否在开窗区间内是则给TT开机
if (isManualWindow() ||isInWindowZone()) {//开机检查是否在开窗区间内是则给TT开机
initTT();
setWindowMode();
}
@ -344,16 +345,17 @@ void resetTM(void)
LOG_E("tmrToPNTT is NULL");
return;
}
if (isManualWindow()) {
stopAlarm();
stopTM();
LOG_W("TIMEOUT stopped.[isManualMode]");
return;
}
if (isWindowMode) {
stopTM();
LOG_W("TIMEOUT stopped.[isWindowMode]");
return;
}
if (isManualWindow()) {
stopTM();
LOG_W("TIMEOUT stopped.[isManualMode]");
return;
}
if (isFileMode) {
stopTM();
LOG_W("TIMEOUT stopped.[isFileMode]");

View File

@ -371,6 +371,12 @@ void setCommWindow(uint8_t *t, size_t len)
len= len/4*4;//窗口需要成对
updateAlarm(t,len);
if (isManualWindow()) {
stopAlarm();
}
else {
startAlarm();
}
memset(scfg.openWindowTime,0,sizeof(scfg.openWindowTime));
memcpy(scfg.openWindowTime,t,len);
// rt_sem_release(cfgUpdate);
@ -423,9 +429,8 @@ void checkManualWindow(void)
if (rst < 0) {//none
return;
}
stopAlarm();
if (rst == 0) {//manual open without auto close
stopAlarm();
return;
}
//设置定时器,定时器到则关窗
@ -458,13 +463,14 @@ void openWindow(int t)
stopAlarm();
if (!t) {
LOG_D("手动开窗完成,需手动关窗。");
return;
// return;
}
else {
//设置定时器,定时器到则关窗
/* 创建定时器,单次定时器 */
rt_timer_t timer1;
timer1 = rt_timer_create("window", closeWindow,
timer1 = rt_timer_create("manualWin", closeWindow,
RT_NULL, rt_tick_from_millisecond(t*60*1000),
RT_TIMER_FLAG_ONE_SHOT);
/* 启动定时器 */
@ -473,6 +479,7 @@ void openWindow(int t)
rt_timer_start(timer1);
LOG_D("手动开窗完成,%d分钟后自动关窗。",t);
}
}
ack();
}