refactor(vd960DBN): tcp_json_srv data_json[2048] 宏化 → TCP_JSON_DATA_BUF_LEN(1024)
三处 char data_json[2048] (sensor_report×2 + loop_param_query×1) 改用头文件宏 TCP_JSON_DATA_BUF_LEN, 默认 1024。 容量核验: format_sensor_json 4通道~660B / format_loop_param_json~920B 均 < 1024, format 函数有 snprintf 溢出保护; 最终帧受 MAX_FRAME=800 截断。 附带: 栈上缓冲 2048→1024 每处省 1KB
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*===========================================================================*/
|
||||
#define TCP_JSON_PORT 5960 // TCP JSON protocol default port
|
||||
#define TCP_JSON_MAX_FRAME 800 //4096 // Max JSON frame length
|
||||
#define TCP_JSON_DATA_BUF_LEN 1024 // 本地 JSON 组装缓冲长度 (data_json)
|
||||
#define TCP_JSON_AUTH_TIMEOUT_MS 60000 // 60s auth timeout (ms)
|
||||
#define TCP_JSON_RECV_BUF_LEN (TCP_JSON_MAX_FRAME * 2)
|
||||
#define TCP_JSON_MAX_PWD_RETRY 3 // Max password retries before lockout
|
||||
|
||||
@@ -829,7 +829,7 @@ static void json_sensor_callback(const uint8_t *pkg, uint16_t len)
|
||||
return;
|
||||
}
|
||||
|
||||
char data_json[2048];
|
||||
char data_json[TCP_JSON_DATA_BUF_LEN];
|
||||
if (format_sensor_json(data_json, sizeof(data_json), &sr) == 0) {
|
||||
char *out = (char *)malloc(TCP_JSON_MAX_FRAME);
|
||||
if (out) {
|
||||
@@ -1102,7 +1102,7 @@ static void json_check_pending(void) {
|
||||
memset(&pg, 0, sizeof(pg));
|
||||
int ret = lup_parse_param_get(g_lup_cmd.resp_buf, g_lup_cmd.resp_len, &pg);
|
||||
if (ret == 0) {
|
||||
char data_json[2048];
|
||||
char data_json[TCP_JSON_DATA_BUF_LEN];
|
||||
if (format_loop_param_json(data_json, sizeof(data_json), &pg) == 0) {
|
||||
json_send_ok(g_json_pending.socket, g_json_pending.msg_id,
|
||||
g_json_pending.cmd, data_json);
|
||||
@@ -1319,7 +1319,7 @@ void tcp_json_push_sensor(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
char data_json[2048];
|
||||
char data_json[TCP_JSON_DATA_BUF_LEN];
|
||||
if (format_sensor_json(data_json, sizeof(data_json), &sr) == 0) {
|
||||
char *out = (char *)malloc(TCP_JSON_MAX_FRAME);
|
||||
if (out) {
|
||||
|
||||
Reference in New Issue
Block a user