diff --git a/applications/alarmer.c b/applications/alarmer.c index 80d3f79..c3324cd 100644 --- a/applications/alarmer.c +++ b/applications/alarmer.c @@ -124,7 +124,7 @@ void InitAlarm() if (alarm[var] != RT_NULL) { rt_alarm_start(alarm[var]); // LOG_D("alarm %d started.",var+1); - LOG_D("alarm %d(%02d) started.",var+1,alarm[var]->wktime.tm_hour+8); + LOG_D("alarm %d(%02d:%02d) started.",var+1,alarm[var]->wktime.tm_hour+8,alarm[var]->wktime.tm_min); } else { LOG_E("Failed to start alarm %d.",var+1); @@ -136,8 +136,9 @@ INIT_APP_EXPORT(InitAlarm); * 更新rtc闹钟 * @param t 每个rtc时刻组成的数组,依次对应开窗时段的开始和结束 */ -void updateAlarm(int *t) +void updateAlarm(uint8_t *t, size_t len) { +// LOG_HEX("alarm",16,t,4); struct rt_alarm_setup setup; static time_t now; @@ -156,27 +157,30 @@ void updateAlarm(int *t) 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]) { rt_alarm_delete(alarm[0]); // } alarm[0] = rt_alarm_create(poTT_callback, &setup); - setup.wktime.tm_hour = t[1]; //开窗1闭合点 + setup.wktime.tm_hour = t[2]; //开窗1闭合点 + setup.wktime.tm_min = t[3]; //开窗1开启点 if (RT_NULL != alarm[1]) { rt_alarm_delete(alarm[1]); // } alarm[1] = rt_alarm_create(pdTT_callback, &setup); - - setup.wktime.tm_hour = t[2]; //开窗2开启点 + setup.wktime.tm_hour = t[4]; //开窗2开启点 + setup.wktime.tm_min = t[5]; //开窗1开启点 if (RT_NULL != alarm[2]) { rt_alarm_delete(alarm[2]); // } alarm[2] = rt_alarm_create(poTT_callback, &setup); - setup.wktime.tm_hour = t[3]; //开窗2闭合点 + setup.wktime.tm_hour = t[6]; //开窗2闭合点 + setup.wktime.tm_min = t[7]; //开窗1开启点 if (RT_NULL != alarm[3]) { rt_alarm_delete(alarm[3]); // @@ -187,7 +191,8 @@ void updateAlarm(int *t) for (size_t var = 0; var < 4; var++) { if (alarm[var] != RT_NULL) { rt_alarm_start(alarm[var]); - LOG_D("alarm %d started.",var+1); +// LOG_D("alarm %d started.",var+1); + LOG_D("alarm %d(%02d:%02d) started.",var+1,alarm[var]->wktime.tm_hour+8,alarm[var]->wktime.tm_min); } else { LOG_E("Failed to start alarm %d.",var+1); diff --git a/applications/func/func.c b/applications/func/func.c index 0c8d846..6164745 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -15,12 +15,16 @@ #define LOG_LVL LOG_LVL_DBG #include - +RT_WEAK int set_cfg(const char *k, const char*v) +{ + return; +} //3.2.1双模通信功能 //1为TT通信,0为BD短报文通信 void setCommMode(int isTT) { + LOG_I("FUNC = setCommMode"); if (isTT) { //change mode @@ -152,7 +156,7 @@ RT_WEAK int upSend(uint8_t *din, size_t len) void selfTest() { LOG_I("FUNC = selftest"); - rt_uint8_t rst[100]={0x5A, 0xA5, 0x32, 0x3E, 0x0A, 0x41}; + rt_uint8_t rst[100]={0x5A, 0xA5, ADDR_ANJI, ADDR_TT, _CMD_SELF_TEST>>8, _CMD_SELF_TEST & 0xff}; int p = 6; rt_uint8_t sysSta=1,xh=0,jh=0,commSpeed=0; //长度 @@ -160,7 +164,7 @@ void selfTest() rst[p++]=0x09; rst[p++] = sysSta; - rst[p++] = xh; + rst[p++] = xh;//xh,jh rst[p++] = jh; rst[p++] = commSpeed; rst[p++] = getPowerLevel(); @@ -194,7 +198,7 @@ void selfTest() */ void setSelfDestructSWT(int setON) { - + LOG_I("FUNC = set selfdestruct"); //write to cfg file set_cfg("SelfDesSW", setON); LOG_D("set SelfDesSW to %s",setON?"ON":"OFF"); @@ -205,6 +209,7 @@ void setSelfDestructSWT(int setON) */ int getSelfDestructSWT() { + LOG_I("FUNC = get selfdestruct"); //load from cfg file int flag = get_cfg("SelfDesSW"); if (flag < 0) { @@ -224,13 +229,14 @@ void selfDestruct() } //3.2.5开、关窗功能 -extern void updateAlarm(int *t); +extern void updateAlarm(uint8_t *t, size_t len); /** * 更新开窗时间,目前支持两组开窗时段。更新会清除之前的开窗设置 */ -void setCommWindow(int *t) +void setCommWindow(uint8_t *t, size_t len) { - updateAlarm(t); + LOG_I("FUNC = setCommWindow"); + updateAlarm(t,len); LOG_D("更新开窗时间完成。"); } /** @@ -266,7 +272,7 @@ void openWindow(int t) */ void closeWindow() { - pwTT_thread_entry("0");//关 机 +// pwTT_thread_entry("0");//关 机 LOG_D("手动关窗完成。"); } @@ -540,7 +546,7 @@ void ttRunCMD(uint8_t *din, size_t len) selfDestruct(); break; case _CFG_COMM_WINDOW: - setCommWindow(din+8);//只支持两组开窗 + setCommWindow(din+8,din+7);//只支持两组开窗,开窗时间为小时、分钟,UTC+0 break; case _CMD_OPEN_WINDOW: openWindow(din[7]?((din[8] << 8) + din[9]):0);//两字节开窗时间 diff --git a/applications/func/func.h b/applications/func/func.h index 79927d5..feaff34 100644 --- a/applications/func/func.h +++ b/applications/func/func.h @@ -67,7 +67,7 @@ enum #define _CMD_RETRY_DATA 0x7006 // -#define _CFG_UPDATE_CFG 0x7001 +#define _CFG_UPDATE_CFG 0x7007 //3S #define _CMD_DEPTH_REQUEST 0x0601 @@ -77,7 +77,7 @@ enum // #define ADDR_ANJI 0x42 //0x42? #define ADDR_TT 0x41 -#define ADDR_3S 0x3E +#define ADDR_3S 0x32 diff --git a/applications/tools.c b/applications/tools.c index f6bc338..e38fb3e 100644 --- a/applications/tools.c +++ b/applications/tools.c @@ -415,8 +415,8 @@ void sysInit() cfgUpdate = rt_sem_create("cfgUpdate", 0, RT_IPC_FLAG_PRIO); rt_sem_release(cfgUpdate);//上电更新值 // rt_hw_stm32_eth_init();//激活网口 -// LOG_D("sysInit"); + LOG_D("sysInit"); } - +MSH_CMD_EXPORT(sysInit,semInit); INIT_APP_EXPORT(sysInit); INIT_APP_EXPORT(updatecfg); diff --git a/applications/ttmsg/ttmsg.c b/applications/ttmsg/ttmsg.c index b7fdfc0..0406730 100644 --- a/applications/ttmsg/ttmsg.c +++ b/applications/ttmsg/ttmsg.c @@ -567,7 +567,7 @@ void recTT_thread_entry() void recTT(void) { /* 创建线程 */ - rt_thread_t thread = rt_thread_create("recTT", recTT_thread_entry, RT_NULL, 1024 * 2, 27, 10); + rt_thread_t thread = rt_thread_create("recTT", recTT_thread_entry, RT_NULL, 1024 * 5, 27, 10); /* 创建成功则启动线程 */ if (thread != RT_NULL) {