fix:删除4G模组tools目录

This commit is contained in:
2026-04-30 17:16:01 +08:00
parent 36fb7fd027
commit 0d7a8564e0
36 changed files with 703 additions and 3205 deletions

View File

@@ -89,7 +89,7 @@ void UDP_ParseTask_Function(void const *argument)
}
else
{
printf("Missing 'code' field\r\n");
printf("Missing 'code' field from \r\n");
cJSON_Delete(root);
}
vPortFree(msg.data);
@@ -145,9 +145,10 @@ void UDPTask_Function(void const *argument)
{
memcpy(msg.data, playload, playload_len);
msg.data[playload_len] = '\0';
// 队列满,释放数据内存
if (xQueueSend(UDP_Message_Queue, &msg, 0) != pdPASS)
{
vPortFree(msg.data);
vPortFree(msg.data);
}
}
}
@@ -178,6 +179,70 @@ void local_on_cmd_callback_power_on(uint8_t stake_index, cJSON *json_pack)
g_charger_manager.charger_piles[stake_index - 1].is_udp_online = true; // 设置桩为本地在线状态
cJSON *root = NULL;
uint8_t *str = NULL;
root = cJSON_CreateObject();
if (root == NULL)
{
printf("Failed to create JSON object for stake %d\r\n", stake_index);
return;
}
/* 添加一条字符串类型的JSON数据(添加一个链表节点) */
cJSON_AddNumberToObject(root, "id", stake_index);
cJSON_AddStringToObject(root, "cmd", "online");
cJSON_AddStringToObject(root, "type", "response");
str = cJSON_Print(root);
udp_send_response(stake_index, str, strlen(str));
free(str);
cJSON_Delete(root);
printf("南向:对电桩 %d 上电回复成功\r\n", stake_index);
}
/**
* @brief 解析充电桩心跳指令
* @note 回复心跳应答
* @param stake_index 桩索引
* @param json_pack json数据包
*/
void local_on_cmd_callback_heartbeat_response(uint8_t stake_index, cJSON *json_pack)
{
if (stake_index > 6)
{
return;
}
//心跳unpack
cJSON *gun_array = cJSON_GetObjectItem(json_pack, "gun");
// 直接判断 type 字段
if (gun_array == NULL || gun_array->type != cJSON_Array)
{
printf(" └── [error] 缺少 gun 数组\r\n");
return;
}
int gun_count = cJSON_GetArraySize(gun_array);
for (int i = 0; i < gun_count; i++)
{
cJSON *gun = cJSON_GetArrayItem(gun_array, i);
if (!gun) continue;
cJSON *id = cJSON_GetObjectItem(gun, "id");
cJSON *state = cJSON_GetObjectItem(gun, "state");
if (!id || !state) continue;
// if (id->valueint == 1) pile->gun1_state = state->valueint;
// if (id->valueint == 2) pile->gun2_state = state->valueint;
printf(" └── [info] 桩%d 枪%d state=%d\r\n", stake_index, id->valueint, state->valueint);
}
//心跳回复组包
cJSON *root = NULL;
char *str = NULL;
root = cJSON_CreateObject();
@@ -189,29 +254,15 @@ void local_on_cmd_callback_power_on(uint8_t stake_index, cJSON *json_pack)
/* 添加一条字符串类型的JSON数据(添加一个链表节点) */
cJSON_AddNumberToObject(root, "id", stake_index);
cJSON_AddStringToObject(root, "cmd", "power_on");
cJSON_AddNumberToObject(root, "code", 1);
cJSON_AddStringToObject(root, "cmd", "heartbeat");
cJSON_AddStringToObject(root, "type", "response");
str = cJSON_Print(root);
udp_send_response(stake_index, str, strlen(str));
free(str);
cJSON_Delete(root);
printf("电桩 %d 上电报文\r\n", stake_index);
}
/**
* @brief 解析充电桩计费模型请求指令
* @note 获取云快充下发的计费模型,回复给充电桩
* @param stake_index 桩索引
* @param json_pack json数据包
*/
void local_on_cmd_callback_get_billing_model(uint8_t stake_index, cJSON *json_pack)
{
if (stake_index > 6)
{
return;
}
printf("南向:对电桩 %d 心跳回复成功\r\n", stake_index);
}
@@ -220,13 +271,17 @@ void handle_udp_downlink(uint8_t id, const char *cmd, cJSON *json_pack)
{
if (cmd == NULL)
return;
if (strcmp(cmd, "power_on") == 0)
// 处理上电指令
if (strcmp(cmd, "online") == 0)
{
printf("南向:收到电桩 %d 上电指令\r\n", id);
local_on_cmd_callback_power_on(id, json_pack);
}
else if (strcmp(cmd, "get_billing_model") == 0)
// 处理心跳指令
else if (strcmp(cmd, "heartbeat") == 0)
{
local_on_cmd_callback_get_billing_model(id, json_pack);
printf("南向:收到电桩 %d 心跳指令\r\n", id);
local_on_cmd_callback_heartbeat_response(id, json_pack);
}
else
{