定时器版本暂时修改完成,等待安卓回复
This commit is contained in:
parent
71c5dbc702
commit
df31dd8c4e
|
|
@ -140,8 +140,8 @@ extern sys_sta_t sys_sta;
|
||||||
extern BAT_Message_t BAT_Message;
|
extern BAT_Message_t BAT_Message;
|
||||||
|
|
||||||
|
|
||||||
extern uint16_t g_car_ctrl_timer; // 定时时间(单位由平台定义)
|
extern uint16_t g_car_ctrl_time; // 定时时间(单位由平台定义)
|
||||||
extern uint16_t g_car_ctrl_timer; // 剩余时间(单位由平台定义)
|
extern uint16_t g_car_ctrl_rest_time; // 剩余时间(单位由平台定义)
|
||||||
extern uint16_t g_car_ctrl_interval; // 本地播报间隔(单位由平台定义)
|
extern uint16_t g_car_ctrl_interval; // 本地播报间隔(单位由平台定义)
|
||||||
|
|
||||||
void control_out_init(void);
|
void control_out_init(void);
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ typedef enum{
|
||||||
Scenic_Fence_Polygon_area_ID = 0xE3, // 当前位置所在景区围栏多边形区域ID, DWORD
|
Scenic_Fence_Polygon_area_ID = 0xE3, // 当前位置所在景区围栏多边形区域ID, DWORD
|
||||||
Ban_Fence_Polygon_area_ID = 0xE4, // 当前位置所在禁止围栏多边形区域ID, DWORD
|
Ban_Fence_Polygon_area_ID = 0xE4, // 当前位置所在禁止围栏多边形区域ID, DWORD
|
||||||
Locked_Condition_ID = 0xE7, // 锁车状态, BYTE
|
Locked_Condition_ID = 0xE7, // 锁车状态, BYTE
|
||||||
|
Rest_Time = 0xE8,
|
||||||
}addi_infoID_t;
|
}addi_infoID_t;
|
||||||
|
|
||||||
// big_标记的参数需以大端方式存储,需手动转换为大端
|
// big_标记的参数需以大端方式存储,需手动转换为大端
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ osMutexId_t term_param_mutex = NULL; // 终端参数项互斥锁
|
||||||
osMutexId_t Polygon_fence_mutex = NULL; // 多边形围栏互斥锁
|
osMutexId_t Polygon_fence_mutex = NULL; // 多边形围栏互斥锁
|
||||||
osMutexId_t update_mutex = NULL; //更新数据状态互斥锁
|
osMutexId_t update_mutex = NULL; //更新数据状态互斥锁
|
||||||
|
|
||||||
|
osTimerId_t g_car_ctrl_timer = NULL;
|
||||||
|
osTimerId_t g_car_ctrl_interval_timer = NULL;
|
||||||
|
|
||||||
|
|
||||||
// 定义全局变量
|
// 定义全局变量
|
||||||
UpdateStatus_t update_status = {
|
UpdateStatus_t update_status = {
|
||||||
.state = UPDATE_IDLE,
|
.state = UPDATE_IDLE,
|
||||||
|
|
@ -53,6 +57,33 @@ static const ParamDescriptor param_descriptors[] = {
|
||||||
{ID_Ban_Fence_Polygon_Delay_OFF, offsetof(set_TermParam_t, Ban_Fence_Polygon_Delay_OFF), sizeof(uint8_t), 0},
|
{ID_Ban_Fence_Polygon_Delay_OFF, offsetof(set_TermParam_t, Ban_Fence_Polygon_Delay_OFF), sizeof(uint8_t), 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 定时时间定时器回调函数
|
||||||
|
void main_timer_callback(void *argument) {
|
||||||
|
// 定时器到期时执行的代码
|
||||||
|
// argument 是创建定时器时传入的参数
|
||||||
|
|
||||||
|
sys_sta.O_door_lock = 0; // 关闭电门锁
|
||||||
|
osTimerStop(g_car_ctrl_interval_timer); // 停止循环播报定时器
|
||||||
|
// 更改上报数据
|
||||||
|
g_car_ctrl_time = 0; //定时时间清零
|
||||||
|
g_car_ctrl_rest_time = 0; // 剩余时间清零
|
||||||
|
g_car_ctrl_interval = 0; //播报时间清零
|
||||||
|
}
|
||||||
|
|
||||||
|
// 播报定时器回调函数
|
||||||
|
void interval_timer_callback(void *argument) {
|
||||||
|
// 定时器到期时执行的代码
|
||||||
|
// argument 是创建定时器时传入的参数
|
||||||
|
g_car_ctrl_rest_time = g_car_ctrl_rest_time - g_car_ctrl_interval;
|
||||||
|
uint16_t res = (g_car_ctrl_time - g_car_ctrl_rest_time) / 60000; //转换成分钟
|
||||||
|
uint16_t res2 = g_car_ctrl_rest_time / 60000;
|
||||||
|
static char buffer[50];
|
||||||
|
snprintf(buffer, sizeof(buffer),"您已游玩%d分钟,还剩下%d分钟", res, res2);
|
||||||
|
local_tts_text_play(buffer,0,0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 释放参数链表
|
// 释放参数链表
|
||||||
void free_param_list(TermParamlist_t* head) {
|
void free_param_list(TermParamlist_t* head) {
|
||||||
TermParamlist_t* current = head;
|
TermParamlist_t* current = head;
|
||||||
|
|
@ -262,15 +293,40 @@ void update_manager_check_timeout(void) {
|
||||||
osMutexRelease(update_mutex);
|
osMutexRelease(update_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 控制车辆状态,参数为5字节数据:byte0控制位,byte1-2定时时间(大端),byte3-4播报间隔(大端)
|
// 控制车辆状态,参数为5字节数据:byte0控制位,byte1-2定时时间(大端),byte3-4播报间隔(大端)
|
||||||
void jt808_Set_CarStatus(const uint8_t status[5]) {
|
void jt808_Set_CarStatus(const uint8_t status[5]) {
|
||||||
uint8_t ctrl = status[0];
|
uint8_t ctrl = status[0];
|
||||||
uint16_t timer = (status[1] << 8) | status[2];
|
uint16_t timer = (status[1] << 8) | status[2];
|
||||||
uint16_t interval = (status[3] << 8) | status[4];
|
uint16_t interval = (status[3] << 8) | status[4];
|
||||||
|
|
||||||
// 保存定时时间和播报间隔到系统状态(需确保sys_sta中有对应成员)
|
// 保存定时时间和播报间隔到系统状态
|
||||||
sys_sta.timer_value = timer;
|
g_car_ctrl_time = timer;
|
||||||
sys_sta.broadcast_interval = interval;
|
g_car_ctrl_rest_time = timer * 60000; //分钟转换成毫秒
|
||||||
|
g_car_ctrl_interval = interval * 60000; //分钟转换成毫秒
|
||||||
|
|
||||||
|
if(g_car_ctrl_timer == NULL)
|
||||||
|
{
|
||||||
|
// 创建主定时器(到期后只触发一次)
|
||||||
|
g_car_ctrl_timer = osTimerNew(main_timer_callback, // 回调函数
|
||||||
|
osTimerOnce, // 定时器类型:osTimerOnce(一次性)或 osTimerPeriodic(周期性)
|
||||||
|
NULL, // 传递给回调的参数指针
|
||||||
|
NULL); // 属性指针,使用默认属性传 NULL
|
||||||
|
}
|
||||||
|
if(g_car_ctrl_interval_timer == NULL)
|
||||||
|
{
|
||||||
|
g_car_ctrl_interval_timer = osTimerNew(interval_timer_callback, // 回调函数
|
||||||
|
osTimerPeriodic, // 定时器类型:osTimerOnce(一次性)或 osTimerPeriodic(周期性)
|
||||||
|
NULL, // 传递给回调的参数指针
|
||||||
|
NULL); // 属性指针,使用默认属性传 NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
if(g_car_ctrl_time >> 0 || g_car_ctrl_interval >> 0) //正常下发定时时间和播放间隔时间
|
||||||
|
{
|
||||||
|
sys_sta.O_door_lock = 1; // 关闭电门锁
|
||||||
|
osTimerStart(g_car_ctrl_timer, g_car_ctrl_time);
|
||||||
|
osTimerStart(g_car_ctrl_interval_timer, g_car_ctrl_interval);
|
||||||
|
}
|
||||||
|
|
||||||
// 原有控制逻辑(基于ctrl字节)
|
// 原有控制逻辑(基于ctrl字节)
|
||||||
if(ctrl & 0x80) { // 恢复出厂设置
|
if(ctrl & 0x80) { // 恢复出厂设置
|
||||||
|
|
@ -598,6 +654,11 @@ void jt808_LocReport_add_tail_addi_info(uint8_t msg_id){
|
||||||
p_head->msg = (void *)(&Rsp_locked_condition);
|
p_head->msg = (void *)(&Rsp_locked_condition);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Rest_Time:{
|
||||||
|
p_head->msg_len = 2;
|
||||||
|
p_head->msg = (void *)(&g_car_ctrl_rest_time);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:{
|
default:{
|
||||||
// TODO: 未知消息ID
|
// TODO: 未知消息ID
|
||||||
jt808_free(p_head);
|
jt808_free(p_head);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue