fix(vd960DBN): iot_connect_broker 加 SourPort + iot_mqtt_send 加 hex dump

- SourPort 参考 WCHNET_CreateTcpMqttSocket 设为 port_dev_udp+1
- iot_mqtt_send 打印前64字节 hex 内容
This commit is contained in:
wangfq
2026-07-06 15:44:22 +08:00
parent 88526158d0
commit 46091639cd
@@ -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);