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,19 +1,19 @@
/**
* @file point_protocol.c
* @brief 充电桩通信协议处理模块
* @details 处理充电桩与充电桩之间的通信协议,包括登录验证、心跳指令、
* 数据上报等功能。支持JSON格式的数据交互通过UDP协议与充电桩通信。
* @date 2025-01-09 14:32:15
* @version 1.0.0
* @copyright Copyright (c) 2026
******************************************************************************
* @file User\Protocol\Point\point_protocol.c
* @author 路淮
* @version v0.1
* @date 2026-05-21
* @brief 充电桩南向通信协议处理
******************************************************************************
*/
#include "point_protocol.h"
/**
* @brief 解析充电桩上电指令
* @brief point_callback_power_on解析充电桩上电指令处理
* @note 设置桩为本地在线状态,发送上电应答
* @param stake_index 桩索引
* @param json_pack json数据包
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_power_on(uint8_t stake_index, cJSON *json_pack)
{
@@ -57,13 +57,14 @@ void point_callback_power_on(uint8_t stake_index, cJSON *json_pack)
}
/**
* @brief 解析充电桩心跳指令
* @brief point_callback_heartbeat解析充电桩心跳指令处理
* @note 回复心跳应答
* @param stake_index 桩索引
* @param json_pack json数据包
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_heartbeat(uint8_t stake_index, cJSON *json_pack)
{
if (stake_index > MAX_CHARGER_COUNT)
{
return;
@@ -121,10 +122,10 @@ void point_callback_heartbeat(uint8_t stake_index, cJSON *json_pack)
}
/**
* @brief 解析充电桩启动充电回复指令APP控制启动
* @brief point_callback_start_charging解析充电桩启动充电回复指令处理
* @note 回复启动充电应答
* @param stake_index 桩索引
* @param json_pack json数据包
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_start_charging(uint8_t stake_index, cJSON *json_pack)
{
@@ -174,10 +175,10 @@ void point_callback_start_charging(uint8_t stake_index, cJSON *json_pack)
}
/**
* @brief 解析充电桩停止充电回复指令APP控制停止
* @brief point_callback_end_charging解析充电桩停止充电回复指令处理
* @note 回复停止充电应答
* @param stake_index 桩索引
* @param json_pack json数据包
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_end_charging(uint8_t stake_index, cJSON *json_pack)
@@ -210,6 +211,7 @@ void point_callback_end_charging(uint8_t stake_index, cJSON *json_pack)
else
gun->charger_state = FAIL_CHARGER_STOP_STATE;
charger_to_server_0X19(stake_index, gun_id);
/*向云快充服务器上报停止充电结果*/
charger_to_server_0X35(stake_index, gun_id, result, err_code);
@@ -218,10 +220,10 @@ void point_callback_end_charging(uint8_t stake_index, cJSON *json_pack)
}
/**
* @brief 解析充电桩实时数据指令
* @brief point_callback_realtime_data解析充电桩实时数据指令处理
* @note 回复实时数据应答
* @param stake_index 桩索引
* @param json_pack json数据包
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_realtime_data(uint8_t stake_index, cJSON *json_pack)
{
@@ -314,7 +316,7 @@ void point_callback_realtime_data(uint8_t stake_index, cJSON *json_pack)
root = cJSON_CreateObject();
if (root == NULL)
{
printf("111Failed to create JSON object for stake %d\r\n", stake_index);
printf("Failed to create JSON object for stake %d\r\n", stake_index);
return;
}
@@ -332,6 +334,12 @@ void point_callback_realtime_data(uint8_t stake_index, cJSON *json_pack)
printf(" └── 网关向桩回复[success] 桩ID:%d 枪ID:%d 实时数据回复成功\r\n", stake_index, gun_idx);
}
/**
* @brief point_callback_settlement_bill结算单指令处理
* @note 处理结算单指令,更新桩的结算单
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_settlement_bill(uint8_t stake_index, cJSON *json_pack)
{
if (stake_index > MAX_CHARGER_COUNT)
@@ -497,7 +505,7 @@ void point_callback_settlement_bill(uint8_t stake_index, cJSON *json_pack)
cJSON *root = cJSON_CreateObject();
if (root == NULL)
{
printf("333Failed to create JSON object for stake %d\r\n", stake_index);
printf("Failed to create JSON object for stake %d\r\n", stake_index);
return;
}
@@ -519,10 +527,10 @@ void point_callback_settlement_bill(uint8_t stake_index, cJSON *json_pack)
}
/**
* @brief 主动停止充电回调
* @brief point_callback_proactive_end_charging主动上报停止充电指令处理
* @note 桩主动上报停止充电,回复应答
* @param id 桩编码 (1~6)
* @param json_pack json数据包
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_proactive_end_charging(uint8_t stake_index, cJSON *json_pack)
{
@@ -546,7 +554,7 @@ void point_callback_proactive_end_charging(uint8_t stake_index, cJSON *json_pack
cJSON *root = cJSON_CreateObject();
if (root == NULL)
{
printf("444Failed to create JSON object for stake %d\r\n", stake_index);
printf("Failed to create JSON object for stake %d\r\n", stake_index);
return;
}
@@ -561,14 +569,16 @@ void point_callback_proactive_end_charging(uint8_t stake_index, cJSON *json_pack
free(str);
cJSON_Delete(root);
charger_to_server_0X19(stake_index, gun_idx);
printf(" └── 网关向桩回复[success] 桩ID: %d 枪ID: %d 主动停止充电回复成功\r\n", stake_index, gun_idx);
}
/**
* @brief 充电过程BMS实时需求上报回调
* @brief point_callback_charge_process充电过程BMS实时需求上报指令处理
* @note 桩周期上报BMS需求与充电机输出数据填充到gun->bms_demand
* @param id 桩编码 (1~6)
* @param json_pack json数据包
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_charge_process(uint8_t stake_index, cJSON *json_pack)
{
@@ -699,6 +709,12 @@ void point_callback_charge_process(uint8_t stake_index, cJSON *json_pack)
}
}
/**
* @brief point_callback_bms_info解析充电桩BMS信息指令处理
* @note 回复BMS信息应答
* @param stake_index 桩索引 (1~6)
* @param json_pack JSON指令指针
*/
void point_callback_bms_info(uint8_t stake_index, cJSON *json_pack)
{
if (stake_index > MAX_CHARGER_COUNT)
@@ -822,8 +838,8 @@ void point_callback_bms_info(uint8_t stake_index, cJSON *json_pack)
}
/**
* @brief 主动下发启动指令
* @note 发送启动指令到充电桩,符合协议格式要求
* @brief point_send_start_charging主动解析充电桩启动充电指令处理
* @note 发送启动充电指令到充电桩,符合协议格式要求
* @param stake_index 桩索引 (1~6)
* @param gun_id 枪编码 (1~N)
*/
@@ -861,7 +877,7 @@ void point_send_start_charging(uint8_t stake_index, uint8_t gun_id)
root = cJSON_CreateObject();
if (root == NULL)
{
printf("555Failed to create JSON object for stake %d\r\n", stake_index);
printf("Failed to create JSON object for stake %d\r\n", stake_index);
return;
}
@@ -879,7 +895,7 @@ void point_send_start_charging(uint8_t stake_index, uint8_t gun_id)
billing_array = cJSON_CreateArray();
if (billing_array == NULL)
{
printf("666Failed to create billing array\r\n");
printf("Failed to create billing array\r\n");
cJSON_Delete(root);
return;
}
@@ -978,7 +994,7 @@ void point_send_start_charging(uint8_t stake_index, uint8_t gun_id)
if (err1 != ERR_OK)
{
printf("error error error UDP 开始充电指令发送失败,桩索引:%d\r\n", stake_index);
printf("UDP 开始充电指令发送失败,桩索引:%d\r\n", stake_index);
}
else
{
@@ -987,14 +1003,14 @@ void point_send_start_charging(uint8_t stake_index, uint8_t gun_id)
}
else
{
printf("777Failed to print JSON for stake %d\r\n", stake_index);
printf("Failed to print JSON for stake %d\r\n", stake_index);
}
cJSON_Delete(root);
}
/**
* @brief 主动下发停止充电指令
* @brief point_send_stop_charging主动解析充电桩停止充电指令处理
* @note 发送停止充电指令到充电桩,符合协议格式要求
* @param stake_index 桩索引 (1~6)
* @param gun_id 枪编码 (1~N)
@@ -1024,7 +1040,7 @@ void point_send_stop_charging(uint8_t stake_index, uint8_t gun_id)
root = cJSON_CreateObject();
if (root == NULL)
{
printf("888Failed to create JSON object for stake %d\r\n", stake_index);
printf("Failed to create JSON object for stake %d\r\n", stake_index);
return;
}
@@ -1042,7 +1058,7 @@ void point_send_stop_charging(uint8_t stake_index, uint8_t gun_id)
free(str);
if (err1 != ERR_OK)
{
printf("error error error UDP 停机指令发送失败,桩索引:%d\r\n", stake_index);
printf("UDP 停机指令发送失败,桩索引:%d\r\n", stake_index);
}
else
{
@@ -1055,7 +1071,7 @@ void point_send_stop_charging(uint8_t stake_index, uint8_t gun_id)
}
/**
* @brief 将16字节的交易序列号转换为32位16进制字符串
* @brief trade_serial_to_string将交易序列号转换为32位16进制字符串
* @param trade_serial 16字节数组
* @param output_str 输出缓冲区至少33字节
*/

View File

@@ -1,3 +1,13 @@
/**
******************************************************************************
* @file User\Protocol\Point\point_protocol.h
* @author 路淮
* @version v0.1
* @date 2026-05-21
* @brief 充电桩南向通信协议头文件
******************************************************************************
*/
#ifndef POINT_HANDLER_H
#define POINT_HANDLER_H
@@ -5,6 +15,7 @@
#include "cJSON.h"
#include <stdint.h>
#include "udp_manager.h"
#include "charger_to_server.h"
/* ── 路由表注册接口─────────────── */
void point_callback_power_on(uint8_t id, cJSON *json); // 上电