From 46091639cd09dbb26cffb6264e92ddda9771e2ca Mon Sep 17 00:00:00 2001 From: wangfq Date: Mon, 6 Jul 2026 15:44:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(vd960DBN):=20iot=5Fconnect=5Fbroker=20?= =?UTF-8?q?=E5=8A=A0=20SourPort=20+=20iot=5Fmqtt=5Fsend=20=E5=8A=A0=20hex?= =?UTF-8?q?=20dump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SourPort 参考 WCHNET_CreateTcpMqttSocket 设为 port_dev_udp+1 - iot_mqtt_send 打印前64字节 hex 内容 --- vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c index 0c8a597..9a706d4 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/iot_mqtt_srv.c @@ -71,7 +71,10 @@ static int iot_make_topic(char *out, uint16_t out_len, const char *direction, /* 发送 MQTT 报文到 broker */ static int iot_mqtt_send(const uint8_t *buf, uint16_t len) { uint16_t slen = len; - PRINT("IOT: SocketSend sock=%d len=%d\n", g_iot_socket, len); + uint8_t i; + PRINT("IOT: SocketSend sock=%d len=%d data:", g_iot_socket, len); + for (i = 0; i < len && i < 64; i++) PRINT(" %02X", buf[i]); + PRINT("\n"); uint8_t ret = WCHNET_SocketSend(g_iot_socket, (uint8_t *)buf, &slen); PRINT("IOT: SocketSend ret=0x%02X sent=%d\n", ret, slen); return (ret == WCHNET_ERR_SUCCESS) ? 0 : -1; @@ -494,6 +497,7 @@ static void iot_connect_broker(void) { memset(&sock_inf, 0, sizeof(SOCK_INF)); sock_inf.DesPort = iot_net_info.mqtt_port; + sock_inf.SourPort = local_net_cfg.port_dev_udp + 1; // 参考 WCHNET_CreateTcpMqttSocket sock_inf.ProtoType = PROTO_TYPE_TCP; sock_inf.RecvBufLen = RECE_BUF_LEN; memcpy(sock_inf.IPAddr, broker_ip, 4);