fix:更新注释等

This commit is contained in:
2026-05-21 12:19:01 +08:00
parent fd65e9c6a2
commit 8ee0849831
54 changed files with 1145 additions and 683 deletions

View File

@@ -1,11 +1,11 @@
/**
* @file udp_manager.c
* @brief UDP管理模块
* @details 处理充电桩与服务器之间的UDP通信提供数据发送功能。
* 支持向指定充电桩发送数据以及向上位机服务器发送数据。
* @date 2025-01-09 14:32:15
* @version 1.0.0
* @copyright Copyright (c) 2026
******************************************************************************
* @file User\Network\udp_manager.c
* @author 路淮
* @version v0.1
* @date 2026-05-21
* @brief UDP管理模块
******************************************************************************
*/
#include "udp_manager.h"
@@ -15,6 +15,7 @@ struct netconn *datalink_conn; // 数据链路句柄
/**
* @brief 桩IP地址
* @note 桩IP地址从10.12.19.101开始递增
* @retval none
*/
static ip4_addr_t s_point_ip[6] = {
IPADDR4_INIT_BYTES(10, 12, 19, 101), /* 桩1 */
@@ -28,11 +29,11 @@ static ip4_addr_t s_point_ip[6] = {
static ip4_addr_t s_server_ip = IPADDR4_INIT_BYTES(10, 12, 19, 107); /* 上位机 */
/**
* @brief UDP发送
* @note 发送数据指定桩
* @param point_id 目标桩ID
* @param data 数据指针
* @param len 数据长度
* @brief udp_send_to_point发送数据到指定桩
* @note 指定桩,数据指定桩,数据指针和长度
* @param point_id目标桩ID1-6表示桩ID
* @param data数据指针
* @param len数据长度
* @return err_t 错误码
*/
err_t udp_send_to_point(uint8_t point_id, uint8_t *data, u16_t len)
@@ -71,6 +72,13 @@ err_t udp_send_to_point(uint8_t point_id, uint8_t *data, u16_t len)
return err;
}
/**
* @brief udp_send_to_server发送数据到上位机
* @note 发送数据到上位机,数据指针和长度
* @param data数据指针
* @param len数据长度
* @return err_t 错误码
*/
err_t udp_send_to_server(uint8_t *data, uint16_t len)
{
struct netbuf *buf = netbuf_new();

View File

@@ -1,10 +1,10 @@
/**
******************************************************************************
* @file user\network\udp_manager.h
* @author luhuaishuai
* @file User\Network\udp_manager.h
* @author 路淮
* @version v0.1
* @date 2023-10-11
* @brief Briefly describe the function of your function
* @date 2026-05-21
* @brief UDP管理模块头文件
******************************************************************************
*/
#ifndef __UDP_MANAGER_H

View File

@@ -1,11 +1,11 @@
/**
* @file udp_router.c
* @brief UDP路由分发模块
* @details 处理充电桩与服务器之间的UDP通信路由分发根据指令字符串匹配对应的处理函数。
* 支持充电桩南向通信和上位机控制两类路由,通过静态路由表实现高效的指令分发。
* @date 2025-01-09 14:32:15
* @version 1.0.0
* @copyright Copyright (c) 2026
******************************************************************************
* @file User\Network\udp_router.c
* @author 路淮
* @version v0.1
* @date 2026-05-21
* @brief UDP路由分发模块
******************************************************************************
*/
#include "udp_router.h"
@@ -32,16 +32,29 @@ static const route_entry_t ROUTE_TABLE[] = {
#define ROUTE_TABLE_SIZE (sizeof(ROUTE_TABLE) / sizeof(ROUTE_TABLE[0]))
/**
* @brief 路由分发入口
* @param id 指令发送的充电桩ID
* @param cmd 指令字符串
* @param json_pack JSON格式的指令参数
* @brief udp_route_dispatch路由分发入口
* @note 路由分发入口根据指令ID和指令字符串调用对应的回调函数
* @param id指令发送的充电桩ID1-6表示桩ID7表示上位机
* @param cmd指令字符串
* @param json_packJSON格式的指令参数
* @retval none
*/
void udp_route_dispatch(uint8_t id, const char *cmd, cJSON *json_pack)
{
if (!cmd)
return;
/* 除 "online"(上电)外,其他所有桩指令都需要桩已上电 */
if (strcmp(cmd, "online") != 0 && id != 7)
{
if (id < 1 || id > MAX_CHARGER_COUNT ||
!g_charger_manager.charger_piles[id - 1].is_udp_online)
{
printf("[ UDP 路由拦截 ] 桩ID: %d 未上电,忽略指令: %s\r\n", id, cmd);
return;
}
}
for (size_t i = 0; i < ROUTE_TABLE_SIZE; i++)
{
if (strcmp(cmd, ROUTE_TABLE[i].cmd) == 0)

View File

@@ -1,8 +1,18 @@
/**
******************************************************************************
* @file User\Network\udp_router.h
* @author 路淮
* @version v0.1
* @date 2026-05-21
* @brief UDP路由分发模块头文件
******************************************************************************
*/
#ifndef __UDP_ROUTER_H
#define __UDP_ROUTER_H
/* includes ----------------------------------------------------------------------------------------------*/
/* includes ------------------------------------------------------------------*/
#include "global.h"
#include "board_config.h"
#include "point_protocol.h"