diff --git a/applications/alarmer.c b/applications/alarmer.c index 01d2375..6742b39 100644 --- a/applications/alarmer.c +++ b/applications/alarmer.c @@ -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 { diff --git a/applications/core.c b/applications/core.c index 5e67777..bd7af8c 100644 --- a/applications/core.c +++ b/applications/core.c @@ -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]"); diff --git a/applications/func/func.c b/applications/func/func.c index 16c7657..68a8416 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -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(); }