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 防栈溢出
This commit is contained in:
@@ -168,7 +168,7 @@ static int iot_mqtt_publish(const char *topic, const char *payload,
|
||||
|
||||
/* 处理一条收到的 MQTT PUBLISH 消息 */
|
||||
static void iot_handle_publish(const char *topic, uint8_t *payload, int payload_len) {
|
||||
char json[IOT_MQTT_RECV_BUF_LEN];
|
||||
static char json[IOT_MQTT_RECV_BUF_LEN]; // static: 避免 1KB 栈开销
|
||||
int copy_len = payload_len < (int)sizeof(json) - 1 ? payload_len : (int)sizeof(json) - 1;
|
||||
memcpy(json, payload, copy_len);
|
||||
json[copy_len] = '\0';
|
||||
@@ -392,7 +392,7 @@ void iot_mqtt_publish_sensor(void) {
|
||||
}
|
||||
|
||||
/* 构建 loop_data JSON */
|
||||
static char data_json[2048]; // static: 避免 2KB 栈溢出
|
||||
static char data_json[IOT_MQTT_SEND_BUF_LEN]; // static: 避免栈溢出
|
||||
char *p = data_json;
|
||||
int remaining = sizeof(data_json);
|
||||
int written;
|
||||
|
||||
Reference in New Issue
Block a user