Files
BR_YKC/Core/User/App/task_air724.c
2026-05-21 12:19:01 +08:00

87 lines
2.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
******************************************************************************
* @file User\App\task_air724.c
* @author 路淮
* @version v0.1
* @date 2026-05-21
* @brief 4G模块通信任务处理模块
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "task_air724.h"
#include "ykc_router.h"
#include "drv_air724.h"
/* typedef --------------------------------------------------------------------*/
/* variables ------------------------------------------------------------------*/
/* code -----------------------------------------------------------------------*/
/**
* @brief tcp_recv_task_function云快充 TCP 消息解析任务
*
* @note none
*
* @param taskID : 任务ID
*
* @retval runtime : 任务周期
*/
void air724_recv_task_function(void const *argument)
{
uint8_t air724_rx_msg[UART1_RX_BUFFER_SIZE];
uint8_t *ykc_downlink_frame = NULL;
/* 等待 datalink_conn 初始化完成 */
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
/**/
while (1)
{
if (xQueueReceive(Air724_Message_Queue, &air724_rx_msg, 10) == pdPASS)
{
if (air724_rx_msg[0] == 0x55 && air724_rx_msg[1] == 0xAA)
{
// 主指令解析
switch (air724_rx_msg[2])
{
// 云快充下行解析
case 0x01:
{
uint8_t charger_index = air724_rx_msg[3];
uint8_t ykc_downlink_frame_len = air724_rx_msg[4];
memcpy(ykc_downlink_frame, &air724_rx_msg[5], ykc_downlink_frame_len);
SERVER_PACK frame;
frame.start_flag = ykc_downlink_frame[0];
frame.len = ykc_downlink_frame[1];
frame.serial = (ykc_downlink_frame[2] << 8) | ykc_downlink_frame[3];
frame.encrypt_flag = ykc_downlink_frame[4];
frame.frame_type = ykc_downlink_frame[5];
frame.data = (uint8_t *)pvPortMalloc(frame.len - 4);
memcpy(frame.data, ykc_downlink_frame + HEADER_LENGTH, frame.len - 4);
frame.crc = (ykc_downlink_frame[HEADER_LENGTH + frame.len] << 8) | ykc_downlink_frame[HEADER_LENGTH + frame.len + 1];
ykc_route_dispatch(charger_index, &frame); // 云快充路由分发
vPortFree(frame.data);
}
break;
case 0x83:
case 0x84:
case 0x85:
case 0x86:
case 0x87:
{
drv_air724_parse_response(air724_rx_msg, UART1_RX_BUFFER_SIZE);// 4G模块回传命令数据解析
}
break;
}
}
}
}
}