2026-03-31 15:46:04 +08:00
|
|
|
|
/**
|
2026-05-21 12:19:01 +08:00
|
|
|
|
******************************************************************************
|
|
|
|
|
|
* @file User\App\task_air724.c
|
|
|
|
|
|
* @author 路淮
|
|
|
|
|
|
* @version v0.1
|
|
|
|
|
|
* @date 2026-05-21
|
|
|
|
|
|
* @brief 4G模块通信任务处理模块
|
|
|
|
|
|
******************************************************************************
|
2026-03-31 15:46:04 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
2026-05-21 10:01:28 +08:00
|
|
|
|
#include "task_air724.h"
|
|
|
|
|
|
#include "ykc_router.h"
|
|
|
|
|
|
#include "drv_air724.h"
|
2026-03-31 15:46:04 +08:00
|
|
|
|
|
|
|
|
|
|
/* typedef --------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/* variables ------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/* code -----------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-21 10:01:28 +08:00
|
|
|
|
* @brief tcp_recv_task_function:云快充 TCP 消息解析任务
|
2026-03-31 15:46:04 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @note none
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param taskID : 任务ID
|
|
|
|
|
|
*
|
|
|
|
|
|
* @retval runtime : 任务周期
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2026-05-21 10:01:28 +08:00
|
|
|
|
void air724_recv_task_function(void const *argument)
|
2026-03-31 15:46:04 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
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])
|
|
|
|
|
|
{
|
2026-05-21 10:01:28 +08:00
|
|
|
|
// 云快充下行解析
|
2026-03-31 15:46:04 +08:00
|
|
|
|
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];
|
|
|
|
|
|
|
2026-05-21 10:01:28 +08:00
|
|
|
|
ykc_route_dispatch(charger_index, &frame); // 云快充路由分发
|
2026-03-31 15:46:04 +08:00
|
|
|
|
|
|
|
|
|
|
vPortFree(frame.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2026-04-30 17:16:01 +08:00
|
|
|
|
case 0x83:
|
2026-05-21 10:01:28 +08:00
|
|
|
|
case 0x84:
|
|
|
|
|
|
case 0x85:
|
|
|
|
|
|
case 0x86:
|
|
|
|
|
|
case 0x87:
|
2026-04-30 17:16:01 +08:00
|
|
|
|
{
|
2026-05-21 12:19:01 +08:00
|
|
|
|
drv_air724_parse_response(air724_rx_msg, UART1_RX_BUFFER_SIZE);// 4G模块回传命令数据解析
|
2026-04-30 17:16:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
2026-03-31 15:46:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|