refactor(vd960DBN): replace compile-time NET_SSC/NET_JSON/NET_IOT macros with runtime g_sub_code_enable.iot_enable
- Remove NET_SSC_ENABLE, NET_JSON_ENABLE, NET_IOT_ENABLE from net_config.h - Socket config always allocates max: 1 UDP + 2 TCP + 1 TCP_LISTEN - All #if guards in net_srv.c/h and peripheral_main.c replaced with runtime g_sub_code_enable.iot_enable checks - iot_enable=0 -> SSC mode (UDP + TCP client + JSON server) - iot_enable=1 -> IoT MQTT mode (MQTT client via iot_mqtt_srv)
This commit is contained in:
@@ -18,39 +18,19 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* Feature toggles (0 = disabled, 1 = enabled)
|
||||
* Feature toggles
|
||||
*
|
||||
* 模式互斥:
|
||||
* NET_SSC_ENABLE=1 → SSC 模式 (UDP+TCP client) + TCP JSON server
|
||||
* NET_SSC_ENABLE=0 → IoT MQTT 模式 (MQTT client)
|
||||
*/
|
||||
#define NET_SSC_ENABLE 0 /* SSC (UDP + TCP client) protocol support */
|
||||
#define NET_JSON_ENABLE 1 /* TCP JSON protocol server (port 5960) */
|
||||
#define NET_IOT_ENABLE (!NET_SSC_ENABLE) /* IoT MQTT client (auto-derived) */
|
||||
|
||||
/*********************************************************************
|
||||
* socket configuration, IPRAW + UDP + TCP + TCP_LISTEN = number of sockets
|
||||
* 模式不再通过编译宏选择, 改为运行时 g_sub_code_enable.iot_enable:
|
||||
* iot_enable=0 → SSC 模式 (UDP+TCP client + TCP JSON server)
|
||||
* iot_enable=1 → IoT MQTT 模式 (MQTT client)
|
||||
*
|
||||
* Socket 数量按最坏情况 (SSC 模式) 静态分配:
|
||||
* 1 UDP + 2 TCP + 1 TCP_LISTEN = 4
|
||||
*/
|
||||
#define WCHNET_NUM_UDP 1 /* SSC 模式需要 UDP */
|
||||
#define WCHNET_NUM_TCP 2 /* JSON(1) + SSC client(1) max */
|
||||
#define WCHNET_NUM_IPRAW 0 /* Number of IPRAW connections */
|
||||
|
||||
#if NET_SSC_ENABLE
|
||||
#define WCHNET_NUM_UDP 1 /* SSC mode: 1 UDP */
|
||||
#else
|
||||
#define WCHNET_NUM_UDP 0 /* IoT mode: 0 UDP */
|
||||
#endif
|
||||
|
||||
#if NET_JSON_ENABLE && NET_SSC_ENABLE
|
||||
#define WCHNET_NUM_TCP 2 /* SSC+JSON: JSON(1) + SSC client(1) */
|
||||
#elif NET_JSON_ENABLE
|
||||
#define WCHNET_NUM_TCP 1 /* JSON only: listen+data(1) */
|
||||
#elif NET_SSC_ENABLE
|
||||
#define WCHNET_NUM_TCP 1 /* SSC only: TCP client(1) */
|
||||
#elif NET_IOT_ENABLE
|
||||
#define WCHNET_NUM_TCP 1 /* IoT MQTT client(1) */
|
||||
#else
|
||||
#define WCHNET_NUM_TCP 0
|
||||
#endif
|
||||
|
||||
#define WCHNET_NUM_TCP_LISTEN 1 /* Number of TCP listening (required internally) */
|
||||
|
||||
/* The number of sockets, the maximum is 31 */
|
||||
|
||||
Reference in New Issue
Block a user