refactor: 用 NET_SSC_ENABLE 宏隔离原有 TCP/UDP 代码,默认=0

net_config.h:
- 新增 NET_SSC_ENABLE=0, NET_JSON_ENABLE=1 功能开关
- WCHNET_NUM_UDP/TCP 根据开关条件编译
- 默认仅保留 JSON TCP server (1 TCP socket),SSC 全部禁用

net_srv.h:
- SocketId_TCP/UDP extern 放入 #if NET_SSC_ENABLE
- WCHNET_CreateTcpSocket/MqttSocket 原型放入 #if

net_srv.c:
- SSC/MQTT 变量和函数全部置入 #if NET_SSC_ENABLE
- WCHNET_HandleSockInt 中 SSC 处理分支置入 #if
- net_srv_init 中 WCHNET_CreateUdpSocket 和 memset(socket) 置入 #if
- JSON routing 保持无条件编译

peripheral_main.c:
- WCHNET_CreateTcpSocket/MqttSocket 调用置入 #if NET_SSC_ENABLE

tcp_json_srv.h:
- 移除 SocketId_TCP/UDP extern(JSON handler 不再引用)

影响:NET_SSC_ENABLE=0 时设备仅运行 TCP JSON server (port 5960),
原有 SSC UDP/TCP/MQTT 代码不参与编译,零干扰。
This commit is contained in:
wangfq
2026-07-01 11:33:32 +08:00
parent ba35ea8ae3
commit e5c99069a0
5 changed files with 71 additions and 30 deletions

View File

@@ -17,16 +17,34 @@
extern "C" {
#endif
/*********************************************************************
* Feature toggles (0 = disabled, 1 = enabled)
*/
#define NET_SSC_ENABLE 0 /* SSC (UDP + TCP client) protocol support */
#define NET_JSON_ENABLE 1 /* TCP JSON protocol server (port 5960) */
/*********************************************************************
* socket configuration, IPRAW + UDP + TCP + TCP_LISTEN = number of sockets
*/
#define WCHNET_NUM_IPRAW 0 /* Number of IPRAW connections */
#if NET_SSC_ENABLE
#define WCHNET_NUM_UDP 1 /* The number of UDP connections */
#else
#define WCHNET_NUM_UDP 0
#endif
#define WCHNET_NUM_TCP 2 /* Number of TCP connections (1 SSC/MQTT + 1 JSON accepted) */
#if NET_JSON_ENABLE && NET_SSC_ENABLE
#define WCHNET_NUM_TCP 2 /* JSON listen+data(1) + SSC client(1) */
#elif NET_JSON_ENABLE
#define WCHNET_NUM_TCP 1 /* JSON listen+data(1) */
#elif NET_SSC_ENABLE
#define WCHNET_NUM_TCP 1 /* SSC client(1) */
#else
#define WCHNET_NUM_TCP 0
#endif
#define WCHNET_NUM_TCP_LISTEN 1 /* Number of TCP listening (JSON protocol on port 5960) */
#define WCHNET_NUM_TCP_LISTEN 1 /* Number of TCP listening (required internally) */
/* The number of sockets, the maximum is 31 */
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)