From c18183969412441a4adf6f136f1b394b8af44913 Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 3 Jul 2026 15:51:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SocketCreat=200x1D=20=E2=80=94=20close?= =?UTF-8?q?=E5=90=8E=E5=85=88=E8=B7=91WCHNET=E5=9B=9E=E6=94=B6=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=86=8Dcreat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: WCHNET_SocketClose 异步, 资源在 WCHNET_MainTask 中释放. tcp_json_restart() close后立刻creat, 旧socket未回收→0x1D. 修复: close后循环5次 WCHNET_MainTask+HandleGlobalInt+Delay(10ms) 确保资源释放后再 WCHNET_SocketCreat --- .../BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c index ef21a8b..d733f99 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c @@ -803,6 +803,18 @@ void tcp_json_restart(void) { g_json_socket_listen = 0xFF; } + /* 1.5 WCHNET 资源回收 — SocketClose 是异步的, 需跑一轮 MainTask */ + { + uint8_t _retry; + for (_retry = 0; _retry < 5; _retry++) { + WCHNET_MainTask(); + if (WCHNET_QueryGlobalInt()) { + WCHNET_HandleGlobalInt(); + } + Delay_Ms(10); + } + } + /* 2. 重置状态 */ g_json_auth_state = JSON_STATE_WAIT_AUTH; g_json_pwd_retry = 0;