基本完成的所有收发功能

This commit is contained in:
2026-05-07 17:47:52 +08:00
parent 61530dccec
commit f05c3106f1
82 changed files with 3008 additions and 4922 deletions

View File

@ -4,7 +4,7 @@
#include "wizchip_conf.h"
/* 【新增】引入多串口路由模块 */
#include "multi_uart_router.h"
#include "main.h"
#if LOOPBACK_MODE == LOOPBACK_MAIN_NOBLCOK
/**
@ -245,18 +245,22 @@ int32_t loopback_udps(uint8_t sn, uint8_t *buf, uint16_t port)
}
size = (uint16_t)ret;
/* ========================================================== *
/* :只在数据前加一个 [NET] 标识,直接透传 */
uint8_t tx_buf[2048]; // 申请一个足够大的临时数组存放拼接后的数据
/* ========================================================== *
/* 🚀 核心修改:网络数据透传时,加上 [0xAA] 和设备 ID */
uint8_t tx_buf[2048];
// 1. 先把网络标识 "[NET]" 写进数组头部tag_len 会自动等于 5
int tag_len = sprintf((char*)tx_buf, "[NET]");
// 1. 添加统一的空中协议头 (0xAA + ID)
tx_buf[0] = 0xAA;
tx_buf[1] = MY_DEVICE_ID;
// 2. 把网络收到的真实数据 (buf) 紧挨着标识拼接到后面
memcpy(tx_buf + tag_len, buf, size);
// 2. 把网络标识 "[NET]" 写进数组,注意要从第 2 个字节开始写
int tag_len = sprintf((char*)&tx_buf[2], "[NET]");
// 3. 把拼接好的整串数据直接发给 RF433
MultiUART_Send(PORT_UART1, tx_buf, tag_len + size);
// 3. 把网络收到的真实数据 (buf) 紧挨着拼接到后面
memcpy(&tx_buf[2 + tag_len], buf, size);
// 4. 把拼接好的整串数据 (头 + ID + [NET] + 数据) 发给 RF433
MultiUART_Send(PORT_UART1, tx_buf, 2 + tag_len + size);
/* ========================================================== */
sentsize = 0;
while (sentsize != size)