Files
STM32F4-Base/Drivers/BSP/NET/net_config.h
T

78 lines
2.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 模块名称:Network Configuration
* 模块功能:网络子系统编译期参数——Socket 数量、收发超时、TCP KeepAlive。
* 仅保留**实际被引用**的宏;未使用项已清理。
* 适用平台:STM32F4 系列(CH395F 以太网芯片)
* 作者:王建锋
* 创建日期:2026-07-18
* 修改记录:
* 2026-09-10 王建锋 清理未引用宏(TCP Server 监听 Socket 索引、收发缓冲、
* 连接/接受超时、select/队列/轮询);KeepAlive 三宏改为
* 实际生效值 60s/5s/3 并在 net_socket.c 引用(原宏为无效遗留值)
* 2026-09-22 新增 NET_RETRANS_COUNT/NET_RETRANS_PERIOD_MS(P0-a:重传周期
* 500→200ms 治 D1 症状),net_socket.c 的字面量 8/500 移入本文件
*/
#ifndef NET_CONFIG_H
#define NET_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* 最大支持的 Socket 数量(CH395F 支持 0~7)
*/
#ifndef NET_MAX_SOCKETS
#define NET_MAX_SOCKETS 8
#endif
/*
* 超时时间配置(毫秒)
* 0 = 无限等待(阻塞模式)
*/
#ifndef NET_SEND_TIMEOUT_MS
#define NET_SEND_TIMEOUT_MS 1000 /* 发送超时 */
#endif
#ifndef NET_RECV_TIMEOUT_MS
#define NET_RECV_TIMEOUT_MS 30000 /* 接收超时(30秒,0=无限等待) */
#endif
/*
* TCP 重传配置(由 net_socket.c 的 net_init() 在 ch395f_init() 之前下发)
* P0-a(2026-09-22):周期 500→200ms——单次丢包代价 500→200ms(治 D1 症状),
* 总窗口 8×200=1.6s,链路真断时判失败更快(对远端显示重连有利)。
* 手册 §5.18 仅标注上限(≤1000ms)未标注下限;200ms 已经台架验证芯片接受
*(GET_CMD_STATUS=0x00 + 全套件无回归,见《链路延迟测试说明.md》§10.2 记录)。
*/
#ifndef NET_RETRANS_COUNT
#define NET_RETRANS_COUNT 8 /* 重传次数(手册:最大 20,默认 12) */
#endif
#ifndef NET_RETRANS_PERIOD_MS
#define NET_RETRANS_PERIOD_MS 200 /* 重传周期 ms(手册:最大 1000,默认 500) */
#endif
/*
* TCP KeepAlive 配置(单位 ms;须为 500 的倍数且 IDLE > INTVL)
* 由 net_socket.c 的 net_init() 在 ch395f_init() 之前下发
*/
#ifndef NET_KEEPALIVE_IDLE_MS
#define NET_KEEPALIVE_IDLE_MS 60000 /* 空闲 60 秒后开始探测 */
#endif
#ifndef NET_KEEPALIVE_INTVL_MS
#define NET_KEEPALIVE_INTVL_MS 5000 /* 5 秒探测一次 */
#endif
#ifndef NET_KEEPALIVE_CNT
#define NET_KEEPALIVE_CNT 3 /* 最多探测 3 次 */
#endif
#ifdef __cplusplus
}
#endif
#endif /* NET_CONFIG_H */