wangfq
46091639cd
fix(vd960DBN): iot_connect_broker 加 SourPort + iot_mqtt_send 加 hex dump
...
- SourPort 参考 WCHNET_CreateTcpMqttSocket 设为 port_dev_udp+1
- iot_mqtt_send 打印前64字节 hex 内容
2026-07-06 15:44:22 +08:00
wangfq
88526158d0
fix(vd960DBN): MQTT CONNECT 改为 poll 内延迟发送,避免中断内 WCHNET_SocketSend 崩溃
...
1. 参考 net_srv.c mqtt_connect 模式重写 iot_mqtt_send_connect:
- clientID 用 g_dev_number_str(全局),不用 g_iot_dev_serial
- username/password 直接赋值,不用 strlen 检查
- memset 手动初始化,不用 brace-initializer 赋值
2. SINT_STAT_CONNECT 中断内不再调 iot_mqtt_send_connect,
改为标记 TCP_CONNECTED,由 iot_mqtt_poll 下一轮发送 —
参考 tcp_json_handle_sock_int 不立即发送数据的模式
2026-07-06 15:16:24 +08:00
wangfq
884a622cab
refactor(vd960DBN): 缓冲区 2048→1024,单次交互不超 1KB
...
- IOT_MQTT_RECV_BUF_LEN: 2048 → 1024
- IOT_MQTT_SEND_BUF_LEN: 2048 → 1024
- data_json 改用宏
- iot_handle_publish 的 json[] 改 static 防栈溢出
2026-07-06 13:47:10 +08:00
wangfq
7459c0fa80
fix(vd960DBN): iot_mqtt_publish_sensor 栈溢出 — data_json[2KB] + payload[2KB] = 4KB 远超 2KB 栈
...
每次主循环调 iot_mqtt_publish_sensor 都分配 4KB 栈变量,
直接栈溢出踩烂全局变量(含 g_iot_dev_serial→clientId=空),
最终在 iot_mqtt_send_connect→WCHNET_SocketSend 时 hard fault。
改为 static 彻底消除栈压力。
另加 iot_mqtt_send 调试日志。
2026-07-06 13:40:25 +08:00
wangfq
de3a7c197e
fix(vd960DBN): MQTTPacket_connectData_initializer 不能用于赋值,用临时变量中转
2026-07-06 11:31:12 +08:00
wangfq
dfadc26717
fix(vd960DBN): MQTT buffer 从栈改为 static,防止栈溢出 (栈仅 2KB)
...
iot_mqtt_send_connect: opts(~85B) + buf[256] → static (~340B 省)
iot_mqtt_send_subscribe: buf[256] → static (256B 省)
iot_mqtt_publish: buf[2048] → static (2KB 省)
调用链 WCHNET_HandleGlobalInt → iot_mqtt_handle_sock_int
→ iot_mqtt_send_connect 会叠加 WCHNET 协议栈内部开销,
2048B 栈极易溢出导致 hard fault(现象:乱码+truncated日志+重启)
2026-07-06 11:27:08 +08:00
wangfq
c0220c1d37
fix(vd960DBN): IoT socket 重复创建 + broker IP 解析错误
...
- iot_connect_broker: 删除 memcpy,get_ipstr_to_array 已正确解析 IP
之前 memcpy 把原始 ASCII 字节覆写到 broker_ip,导致 IP 变成 49.50.49.46
- peripheral_main.c: IoT 模式下跳过 WCHNET_CreateTcpMqttSocket,
由 iot_connect_broker() 统一管理 socket 生命周期,避免重复创建
2026-07-06 10:46:51 +08:00
wangfq
e6dbdb5296
fix(vd960DBN): 修复无法设置 IoT 模式的 bug
2026-07-06 10:24:15 +08:00
wangfq
39bda6067f
fix(vd960DBN): add missing closing brace for case PUBLISH block in iot_process_recv
...
case PUBLISH: { ... } was missing its closing }, causing ARMCC to think
iot_send_heartbeat and iot_connect_broker were declared inside a function body.
2026-07-03 18:28:40 +08:00
wangfq
122c36bb9d
fix(vd960DBN): iot_make_topic missing 5th arg for "srv"/"ctrl" topic
2026-07-03 18:18:38 +08:00
wangfq
6f5effae8c
fix(vd960DBN): iot_mqtt_srv compilation errors
...
- Add extern g_report_active (from tcp_json_srv.h)
- Fix iot_make_topic call: 4-arg -> 5-arg (add NULL for 'status' sub)
- Fix SOCK_INF field names: DestPort->DesPort, DestAddr->IPAddr
- Fix struct _WCHNET_IPAddr -> uint8_t broker_ip[4] (type not available)
2026-07-03 18:12:55 +08:00
wangfq
9629729dc9
feat: IoT MQTT 客户端实现 — NET_SSC_ENABLE=0 时启用
...
新增文件:
- iot_mqtt_srv.h/c: MQTT 客户端 (TCP→CONNECT→SUBSCRIBE→READY)
支持: dev_info_query, pwd_verify (其他命令框架预留)
上报: loop_data (传感器), heartbeat (心跳 60s)
断线重连: 指数退避 5s~60s
协议: DLD960 IoT MQTT V1.00 (dld960/{sn}/...)
修改:
- net_config.h: 新增 NET_IOT_ENABLE = !NET_SSC_ENABLE,
IoT 模式分配 1 TCP socket (MQTT client)
- net_srv.c: IoT 初始化 + socket 中断路由
- peripheral_main.c: IoT poll + sensor publish 调用
模式:
NET_SSC_ENABLE=1 → SCC + TCP JSON Server (原有行为)
NET_SSC_ENABLE=0 → IoT MQTT Client (新增)
2026-07-03 17:36:22 +08:00