diff --git a/Application/CLS b/Application/CLS index 4620d0a..4744762 160000 --- a/Application/CLS +++ b/Application/CLS @@ -1 +1 @@ -Subproject commit 4620d0a7ede7812eb1e1cbcf5ba6528e494ceab8 +Subproject commit 4744762b4c3736d4ea2ec4dba3a70e996763841e diff --git a/Application/Tasks/CanDataTask.c b/Application/Tasks/CanDataTask.c index e35aebe..b4d170f 100644 --- a/Application/Tasks/CanDataTask.c +++ b/Application/Tasks/CanDataTask.c @@ -245,7 +245,6 @@ void CarCanTask_func(void *argument) { if (HAL_FDCAN_GetRxMessage(&hfdcan2, FDCAN_RX_FIFO1, &RxHeader, RxData) != HAL_OK) { Error_Handler(); } else { - char msg[17] = {0}; Vehicle_Receive_CAN(RxHeader, RxData); diff --git a/Application/Vehicle/Vehicle.c b/Application/Vehicle/Vehicle.c index 7f82dab..f9ad940 100644 --- a/Application/Vehicle/Vehicle.c +++ b/Application/Vehicle/Vehicle.c @@ -58,6 +58,8 @@ bool Vehicle_isK15On() { + + #include "CLS.h" #include "CLS_BSP.h" #include "CLSAddress.h" @@ -73,6 +75,7 @@ void CLS_VehicleHeatbeat(void *argument) { status.headlight = Vehicle_isHeadlightOn(); status.engine = Vehicle_isEngineRunning(); status.speed = (uint8_t)Vehicle_Speed(); + status.unlocked = Vehicle_UnlockedSignal(); CLS_BSP_CAN_AddMessageToSend(&cls_vehicle_header, (uint8_t*)&status); diff --git a/Application/Vehicle/Vehicle.h b/Application/Vehicle/Vehicle.h index 27d591a..1e85260 100644 --- a/Application/Vehicle/Vehicle.h +++ b/Application/Vehicle/Vehicle.h @@ -19,4 +19,5 @@ void Vehicle_Receive_CAN( FDCAN_RxHeaderTypeDef header, uint8_t* data); bool Vehicle_gotUnlockMessage(); uint8_t Vehicle_Brightness(); float Vehicle_Speed(); -int Vehicle_DirectionIsForward(); \ No newline at end of file +int Vehicle_DirectionIsForward(); +bool Vehicle_UnlockedSignal(); \ No newline at end of file diff --git a/Application/Vehicle/Vehicle_can.c b/Application/Vehicle/Vehicle_can.c index ff603c9..f278128 100644 --- a/Application/Vehicle/Vehicle_can.c +++ b/Application/Vehicle/Vehicle_can.c @@ -107,4 +107,26 @@ float Vehicle_Speed() { int Vehicle_DirectionIsForward() { return car_can_direction == 0; +} + + +static bool unlocked = false; + + +bool Vehicle_UnlockedSignal() { + + if (unlocked) { + if(Vehicle_isK15On()) { + unlocked = false; + last_unlock_message_time = UINT64_MAX; + } + } + + if (!unlocked) { + if (Vehicle_gotUnlockMessage()) { + unlocked = true; + } + } + + return unlocked; } \ No newline at end of file diff --git a/proto b/proto index 2142d03..4ff29f9 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 2142d035868474d3ab10ec54368a10957e7db1b9 +Subproject commit 4ff29f9d5bb66ba09e48e97a45ed0b5ea206a0e0