refactor: RAM 优化 — 合并分散 buffer 为共享全局 buffer
net_srv.c: - 新增 g_work_buf[1024] 共享全局 buffer - 替换 manage_mqtt_recv_message() 中 14 处 malloc/free + 14 处栈上 resp[N] - 消除 mqtt_data_manage() 中重复的 static MyBuf[1152],复用全局 MyBuf - expand MAX_MQTTBUF_LEN 512→1280 (移到 net_srv.h) - 新增 WORK_BUF_SIZE 宏,修复 sizeof(resp) 指针截断 bug iot_mqtt_srv.c: - iot_mqtt_publish() 复用 net_srv.c 的 mqttBuf[1280],移除自有 static buf[1024] net_srv.h: - 新增 MAX_MQTTBUF_LEN 宏定义 (1280) 收益: - 消除 ~14 次 malloc/free 堆操作 (CH32V208 堆极小,malloc 容易失败) - BSS 节省 ~1152 + 1024 = 2176 字节 - 减少中断上下文栈压力 (移除 ~5KB 栈上临时数组)
This commit is contained in:
@@ -105,6 +105,8 @@ extern IOT_Topic g_iot_topic;
|
||||
|
||||
#define MQTT_KEEPALIVE_INTERVAL 9
|
||||
|
||||
#define MAX_MQTTBUF_LEN 1280 // MQTT send buffer (PUBLISH with sensor JSON)
|
||||
|
||||
|
||||
typedef struct _NET_STATE_
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user