Files
BR_YKC/Core/User/App/task_air724.c

91 lines
3.2 KiB
C
Raw Normal View History

2026-03-31 15:46:04 +08:00
/**
2026-05-21 10:01:28 +08:00
* @file udp_manager.c
* @brief UDP管理模块
* @details UDP通信
*
* @date 2025-01-09 14:32:15
* @version 1.0.0
* @copyright Copyright (c) 2026
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)
{
/*---------------------------------------------------获取任务运行状态---------------------------------------------------*/
TaskRunTimeStat.DownLinkTask.threads_runtime = GetTask_RunTime(DownLinkTaskID);
TaskRunTimeStat.DownLinkTask.threads_counter = GetTask_Beatcnt(DownLinkTaskID);
TaskRunTimeStat.DownLinkTask.threads_freestack = Get_Free_Stack(DownLinkTaskID);
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 10:01:28 +08:00
drv_air724_parse_response(air724_rx_msg, UART1_RX_BUFFER_SIZE);
2026-04-30 17:16:01 +08:00
}
break;
2026-03-31 15:46:04 +08:00
}
}
}
}
}