From: 孙春阳 Date: Sun, 21 Sep 2025 16:10:56 +0000 (+0800) Subject: 修复ppp收发统计 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~1^2~2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=0bda566ab20af948c373fa07d3fcaa1676587c7b;p=mirrors%2FFD230.git 修复ppp收发统计 --- diff --git a/code/sdk/zhihui/ppp/src/ppp_api.c b/code/sdk/zhihui/ppp/src/ppp_api.c index d16ff1435..2006607cf 100644 --- a/code/sdk/zhihui/ppp/src/ppp_api.c +++ b/code/sdk/zhihui/ppp/src/ppp_api.c @@ -1178,6 +1178,12 @@ static errcode_t ppp_parse_network_status_response(const char *response, uint8_t */ errcode_t ppp_api_update_imei(void) { + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot update IMEI: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + char *response = (char *)malloc(512); // 动态分配内存 if (response == NULL) { PPP_DEBUG_ERROR("Failed to allocate memory for AT response"); @@ -1216,6 +1222,12 @@ errcode_t ppp_api_update_imei(void) */ errcode_t ppp_api_update_signal(void) { + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot update signal: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + char *response = (char *)malloc(512); // 动态分配内存 if (response == NULL) { PPP_DEBUG_ERROR("Failed to allocate memory for AT response"); @@ -1254,6 +1266,12 @@ errcode_t ppp_api_update_signal(void) */ errcode_t ppp_api_update_operator(void) { + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot update operator: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + char *response = (char *)malloc(512); // 动态分配内存 if (response == NULL) { PPP_DEBUG_ERROR("Failed to allocate memory for AT response"); @@ -1292,6 +1310,12 @@ errcode_t ppp_api_update_operator(void) */ errcode_t ppp_api_update_iccid(void) { + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot update ICCID: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + char *response = (char *)malloc(512); // 动态分配内存 if (response == NULL) { PPP_DEBUG_ERROR("Failed to allocate memory for AT response"); @@ -1330,6 +1354,12 @@ errcode_t ppp_api_update_iccid(void) */ errcode_t ppp_api_update_version(void) { + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot update version: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + char *response = (char *)malloc(512); // 动态分配内存 if (response == NULL) { PPP_DEBUG_ERROR("Failed to allocate memory for AT response"); @@ -1368,6 +1398,12 @@ errcode_t ppp_api_update_version(void) */ errcode_t ppp_api_update_network_status(void) { + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot update network status: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + char *response = (char *)malloc(512); // 动态分配内存 if (response == NULL) { PPP_DEBUG_ERROR("Failed to allocate memory for AT response"); @@ -1424,6 +1460,12 @@ errcode_t ppp_api_update_network_status(void) */ errcode_t ppp_api_update_sim_status(void) { + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot update SIM status: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + char *response = (char *)malloc(512); // 动态分配内存 if (response == NULL) { PPP_DEBUG_ERROR("Failed to allocate memory for AT response"); @@ -2289,6 +2331,12 @@ errcode_t ppp_get_network_signal_info(void) return ERRCODE_FAIL; } + // 检查是否在AT模式 + if (ppp_serial_get_mode() != PPP_SERIAL_MODE_AT) { + PPP_DEBUG_WARN("Cannot get network signal info: not in AT mode (current mode: %d)", ppp_serial_get_mode()); + return ERRCODE_FAIL; + } + PPP_DEBUG_INFO("Getting network signal information..."); ppp_network_signal_info_t signal_info; diff --git a/code/sdk/zhihui/ppp/src/ppp_lwip_thread.c b/code/sdk/zhihui/ppp/src/ppp_lwip_thread.c index 57bcf18fc..7ee2a77a9 100644 --- a/code/sdk/zhihui/ppp/src/ppp_lwip_thread.c +++ b/code/sdk/zhihui/ppp/src/ppp_lwip_thread.c @@ -333,9 +333,14 @@ static void ppp_lwip_process_thread(void *arg) processed_frames++; processed_bytes += frame->length; - // 更新处理统计 + // 更新处理统计(统计实际传递给lwIP的字节数,但排除我们添加的0x7E) g_ppp_discard_stats.total_frames_processed++; - g_ppp_discard_stats.total_bytes_processed += frame->length; + // 减去我们添加的额外0x7E标志(每帧最多添加1个) + uint32_t original_bytes = frame->length; + if (frame->length > 0 && frame->data[frame->length-1] == 0x7E) { + original_bytes--; // 减去结束时添加的0x7E + } + g_ppp_discard_stats.total_bytes_processed += original_bytes; // 释放帧内存 free(frame->data);