From 6b33c2556517ff2d2d8d53cde9883a60c7d5e3cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AD=99=E6=98=A5=E9=98=B3?= Date: Thu, 25 Sep 2025 18:33:33 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96ppp=E6=8B=A8=E5=8F=B7=EF=BC=8C?= =?utf8?q?=E4=BC=98=E5=8C=96tcp=E6=B5=8B=E8=AF=95=E7=A8=8B=E5=BA=8F?= =?utf8?q?=EF=BC=8Cppp=E4=B8=B2=E5=8F=A3=E5=88=9D=E5=A7=8B=E5=8C=96?= =?utf8?q?=E7=A7=BB=E5=8A=A8=E5=88=B0uart=5Fporting.c=E4=B8=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../brandy/brandy_standard/thread_pri_init.c | 8 +- .../config/target_config/brandy/config.py | 1 + .../chips/brandy/porting/uart/uart_porting.c | 33 +- code/sdk/zhihui/leiniao/imsl_ln/ln_api.c | 4 + code/sdk/zhihui/ppp/README.md | 1 - .../zhihui/ppp/README_CAT1_COMPATIBILITY.md | 1 - code/sdk/zhihui/ppp/README_POWER_CONTROL.md | 1 - code/sdk/zhihui/ppp/build_test.sh | 195 ------- code/sdk/zhihui/ppp/doc/Neoway-pppdial | 64 +++ code/sdk/zhihui/ppp/example/ppp_at_cmd.c | 213 +++++--- code/sdk/zhihui/ppp/example/ppp_example.c | 16 +- code/sdk/zhihui/ppp/include/ppp_api.h | 19 +- code/sdk/zhihui/ppp/include/ppp_at_handler.h | 2 +- code/sdk/zhihui/ppp/include/ppp_config.h | 6 +- code/sdk/zhihui/ppp/include/ppp_lwip.h | 20 + .../ppp/include/ppp_performance_config.h | 176 ------ code/sdk/zhihui/ppp/include/ppp_serial.h | 5 - code/sdk/zhihui/ppp/src/ppp_api.c | 215 ++++---- code/sdk/zhihui/ppp/src/ppp_at_handler.c | 263 +++++---- code/sdk/zhihui/ppp/src/ppp_cat1_api.c | 7 + code/sdk/zhihui/ppp/src/ppp_lwip.c | 100 ++++ code/sdk/zhihui/ppp/src/ppp_serial.c | 47 +- .../zhihui/tcptest/include/zhihui_tcp_debug.h | 3 + .../zhihui/tcptest/include/zhihui_tcp_test.h | 61 ++- code/sdk/zhihui/tcptest/src/zhihui_tcp_test.c | 503 +++++++++++------- .../zhihui/tcptest/src/zhihui_tcp_test_main.c | 13 +- code/sdk/zhihui/utils/custom_utils.c | 20 +- 27 files changed, 1041 insertions(+), 956 deletions(-) delete mode 100644 code/sdk/zhihui/ppp/README.md delete mode 100644 code/sdk/zhihui/ppp/README_CAT1_COMPATIBILITY.md delete mode 100644 code/sdk/zhihui/ppp/README_POWER_CONTROL.md delete mode 100644 code/sdk/zhihui/ppp/build_test.sh create mode 100644 code/sdk/zhihui/ppp/doc/Neoway-pppdial delete mode 100644 code/sdk/zhihui/ppp/include/ppp_performance_config.h diff --git a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c index a884919d0..2ec1c9291 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c @@ -634,13 +634,9 @@ static void thread_main(const void *unused) custom_check_factory_test_flag(); startup_post_init(); #endif + set_startup_finish_flag(); -#ifdef SUPPORT_LEINIAO -#ifdef CUSTOM_UTILS - if(!custom_get_factory_test_flag()) -#endif - uapi_ln_http_server_init(); -#endif + } void thread_pri_init(void) diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index b5b73d814..2ebecbc56 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -1283,6 +1283,7 @@ target = { 'AUDIO_SMARTPA_AW88082', 'LCD_JD9885', 'SUPPORT_LEINIAO', + # 'SKIP_LN_PROTOCOL_TEST', ], #添加自定义应用 'ram_component': [ diff --git a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c index be6daf1df..943f14927 100644 --- a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c +++ b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c @@ -167,7 +167,7 @@ static uart_config_t g_uart_config[UART_BUS_MAX_NUMBER] = { /** UART_BUS_0, which is used to at cmd and debug print in wstp version, * and which is used to testustie and debug print in testsuite version */ - #if defined(SUPPORT_CAT1_SERVICE) || defined(SUPPORT_PPP_SERVICE) + #if defined(SUPPORT_CAT1_SERVICE) { { .tx_pin = PIN_NONE, @@ -201,7 +201,36 @@ static uart_config_t g_uart_config[UART_BUS_MAX_NUMBER] = { true, #endif }, - + #elif defined(SUPPORT_PPP_SERVICE) + { + { + .tx_pin = S_MGPIO19, + .rx_pin = S_MGPIO20, + .cts_pin = PIN_NONE, + .rts_pin = PIN_NONE + }, + { + .tx_pin_mode = (pin_mode_t)HAL_PIO_FUNC_UART1, + .rx_pin_mode = (pin_mode_t)HAL_PIO_FUNC_UART1, + .cts_pin_mode = (pin_mode_t)HAL_PIO_FUNC_MAX, + .rts_pin_mode = (pin_mode_t)HAL_PIO_FUNC_MAX + }, + UART_0_IRQN, + (osal_irq_handler)irq_uart0_handler, + NULL, + { + .baud_rate = CUSTOM_UART_RATE, + .data_bits = UART_DATA_BIT_8, + .parity = UART_PARITY_NONE, + .stop_bits = UART_STOP_BIT_1, + }, + { + .rx_buffer_size = UART_RX_BUFFER_SIZE, + .rx_buffer = g_uart0_rx_buffer, + }, + NULL, + false, + }, #else // SUPPORT_CAT1_SERVICE { { diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c index 698f1bed8..5419e5e61 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -1276,6 +1276,10 @@ static void ln_http_server_send_task(void const *arg) } if (mail.cmd == LN_HTTP_SERVICE_CMD_GET_DEVICE_TOKEN) { + + #ifdef SKIP_LN_PROTOCOL_TEST + continue; + #endif if(get_is_ln_get_device_token_success() == 1) { printf("设备Token已经获取\n"); diff --git a/code/sdk/zhihui/ppp/README.md b/code/sdk/zhihui/ppp/README.md deleted file mode 100644 index 0519ecba6..000000000 --- a/code/sdk/zhihui/ppp/README.md +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/README_CAT1_COMPATIBILITY.md b/code/sdk/zhihui/ppp/README_CAT1_COMPATIBILITY.md deleted file mode 100644 index 0519ecba6..000000000 --- a/code/sdk/zhihui/ppp/README_CAT1_COMPATIBILITY.md +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/README_POWER_CONTROL.md b/code/sdk/zhihui/ppp/README_POWER_CONTROL.md deleted file mode 100644 index 0519ecba6..000000000 --- a/code/sdk/zhihui/ppp/README_POWER_CONTROL.md +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/build_test.sh b/code/sdk/zhihui/ppp/build_test.sh deleted file mode 100644 index 76f06d3d6..000000000 --- a/code/sdk/zhihui/ppp/build_test.sh +++ /dev/null @@ -1,195 +0,0 @@ -#!/bin/bash - -# PPP模块编译测试脚本 -# 用于验证PPP模块的编译完整性 - -echo "==========================================" -echo "PPP Module Build Test" -echo "==========================================" - -# 设置项目根目录 -PROJECT_ROOT=$(cd "$(dirname "$0")/../../.." && pwd) -PPP_DIR="$PROJECT_ROOT/zhihui/ppp" - -echo "Project Root: $PROJECT_ROOT" -echo "PPP Directory: $PPP_DIR" - -# 检查必要文件是否存在 -echo "" -echo "Checking required files..." - -required_files=( - "include/ppp_api.h" - "include/ppp_config.h" - "include/ppp_types.h" - "include/ppp_at_handler.h" - "include/ppp_serial.h" - "include/ppp_lwip.h" - "include/ppp_debug.h" - "src/ppp_api.c" - "src/ppp_at_handler.c" - "src/ppp_serial.c" - "src/ppp_lwip.c" - "src/ppp_debug.c" - "CMakeLists.txt" - "README.md" -) - -missing_files=0 -for file in "${required_files[@]}"; do - if [ -f "$PPP_DIR/$file" ]; then - echo "✓ $file" - else - echo "✗ $file (MISSING)" - missing_files=$((missing_files + 1)) - fi -done - -if [ $missing_files -gt 0 ]; then - echo "" - echo "ERROR: $missing_files required files are missing!" - exit 1 -fi - -echo "" -echo "All required files found!" - -# 检查头文件包含关系 -echo "" -echo "Checking header dependencies..." - -# 简单的语法检查(如果有gcc可用) -if command -v gcc >/dev/null 2>&1; then - echo "Running syntax check with GCC..." - - # 创建临时测试文件 - test_file="/tmp/ppp_test.c" - cat > "$test_file" << 'EOF' -#include -#include -#include -#include - -// 模拟系统头文件 -#define ERRCODE_SUCC 0 -#define OSAL_SUCCESS 0 -#define OSAL_WAIT_FOREVER -1 -#define UART_BUS_1 1 -#define S_MGPIO33 33 -#define S_MGPIO34 34 -#define PIN_NONE 0xFF -#define UART_DATA_BIT_8 8 -#define UART_PARITY_NONE 0 -#define UART_STOP_BIT_1 1 -#define UART_RX_CONDITION_FULL_OR_SUFFICIENT_DATA_OR_IDLE 1 - -typedef int errcode_t; -typedef void* osal_mutex; -typedef void* osal_semaphore; -typedef void* osal_timer; -typedef void* osal_task; - -typedef struct { - uint8_t tx_pin; - uint8_t rx_pin; - uint8_t cts_pin; - uint8_t rts_pin; -} uart_pin_config_t; - -typedef struct { - uint32_t baud_rate; - uint8_t data_bits; - uint8_t parity; - uint8_t stop_bits; -} uart_attr_t; - -typedef struct { - uint32_t rx_buffer_size; - uint8_t *rx_buffer; -} uart_buffer_config_t; - -// 模拟函数声明 -#define PRINT printf -#define osal_kmalloc malloc -#define osal_kfree free -#define osal_get_tick() 0 -#define osal_msleep(x) -int osal_mutex_init(osal_mutex *mutex) { return 0; } -int osal_mutex_destroy(osal_mutex mutex) { return 0; } -int osal_mutex_lock(osal_mutex mutex) { return 0; } -int osal_mutex_unlock(osal_mutex mutex) { return 0; } -int osal_sem_init(osal_semaphore *sem, int value) { return 0; } -int osal_sem_destroy(osal_semaphore sem) { return 0; } -int osal_sem_wait(osal_semaphore sem, int timeout) { return 0; } -int osal_sem_signal(osal_semaphore sem) { return 0; } -int memset_s(void *dest, size_t destMax, int c, size_t count) { return 0; } -int memcpy_s(void *dest, size_t destMax, const void *src, size_t count) { return 0; } -int snprintf_s(char *strDest, size_t destMax, size_t count, const char *format, ...) { return 0; } - -EOF - - # 添加PPP头文件内容进行语法检查 - echo '#include "'$PPP_DIR'/include/ppp_config.h"' >> "$test_file" - echo '#include "'$PPP_DIR'/include/ppp_types.h"' >> "$test_file" - echo '#include "'$PPP_DIR'/include/ppp_debug.h"' >> "$test_file" - echo '#include "'$PPP_DIR'/include/ppp_api.h"' >> "$test_file" - - echo "int main() { return 0; }" >> "$test_file" - - if gcc -fsyntax-only -I"$PPP_DIR/include" "$test_file" 2>/dev/null; then - echo "✓ Header syntax check passed" - else - echo "✗ Header syntax check failed" - echo "Running detailed check..." - gcc -fsyntax-only -I"$PPP_DIR/include" "$test_file" - fi - - rm -f "$test_file" -else - echo "GCC not available, skipping syntax check" -fi - -# 统计代码行数 -echo "" -echo "Code statistics:" -total_lines=0 -for file in src/*.c include/*.h; do - if [ -f "$PPP_DIR/$file" ]; then - lines=$(wc -l < "$PPP_DIR/$file") - echo " $file: $lines lines" - total_lines=$((total_lines + lines)) - fi -done -echo " Total: $total_lines lines" - -# 检查文档 -echo "" -echo "Documentation:" -if [ -f "$PPP_DIR/README.md" ]; then - readme_lines=$(wc -l < "$PPP_DIR/README.md") - echo " README.md: $readme_lines lines" -fi - -if [ -f "$PPP_DIR/example/ppp_example.c" ]; then - example_lines=$(wc -l < "$PPP_DIR/example/ppp_example.c") - echo " Example code: $example_lines lines" -fi - -echo "" -echo "==========================================" -echo "PPP Module Build Test Completed" -echo "==========================================" -echo "" -echo "Summary:" -echo " ✓ All required files present" -echo " ✓ Header dependencies OK" -echo " ✓ Code statistics generated" -echo " ✓ Documentation available" -echo "" -echo "The PPP module is ready for integration!" -echo "" -echo "Next steps:" -echo "1. Add PPP module to main CMakeLists.txt" -echo "2. Configure lwIP with PPP support" -echo "3. Test with actual hardware" -echo "" \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/doc/Neoway-pppdial b/code/sdk/zhihui/ppp/doc/Neoway-pppdial new file mode 100644 index 000000000..646d3c242 --- /dev/null +++ b/code/sdk/zhihui/ppp/doc/Neoway-pppdial @@ -0,0 +1,64 @@ +# /etc/ppp/peers/Neoway-pppdial +# Usage:root@neoway:~# pppd call Neoway-pppdial + +crtscts +modem + +# Hide password in debug messages +#hide-password + +# The phone is not required to authenticate +noauth + +# The chat script (be sure to edit that file,too!) +connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat' + +# The close script(be sure to edit that file,too!) +#disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/Neoway-chat-disconnect' + +# Debug info from pppd +debug + +# Serial Device to whih phone is connect +#/dev/ttyACM7 +/dev/ttyUSB0 +#/dev/ttyUSB4 +#/dev/mux0 + +# Serial port line speed +115200 + + +# If you want to use the link as your gateway +defaultroute + +# pppd must not propose any IP address to the peer +noipdefault + +# No ppp compression +novj +novjccomp +noccp +ipcp-accept-local +ipcp-accept-remote +local + +# For sanity, keep a lock on the serial line +lock +dump + +# Keep pppd attached to the terminal +# Comment this to get daemon mode pppd +nodetach +#user "card@cc.sg.jl" +#0.0.0.0:0.0.0.0 +#password "card@123" +# Hardware flow control +#crtscts +#remotename 3gppp +#ipparam 3gppp + +# Ask the peer for up to 2 DNS server addresses +usepeerdns + ++ipv6 diff --git a/code/sdk/zhihui/ppp/example/ppp_at_cmd.c b/code/sdk/zhihui/ppp/example/ppp_at_cmd.c index e796366c4..118f4aa9a 100644 --- a/code/sdk/zhihui/ppp/example/ppp_at_cmd.c +++ b/code/sdk/zhihui/ppp/example/ppp_at_cmd.c @@ -11,10 +11,12 @@ #include "ppp_serial.h" #include "ppp_types.h" #include "ppp_api.h" +#include "ppp_lwip.h" #include "ppp_at_handler.h" #include "ppp_debug_manager.h" #include "zhihui_tcp_test.h" #include "ppp_example.h" +#include "uart.h" @@ -613,32 +615,6 @@ static uint32_t at_ws_multi_test_status(uint8_t *para, uint32_t paraLen, char *s } #endif -/* PPP串口模式切换测试指令 */ -static errcode_t at_ppp_mode_switch(uint8_t *para, uint32_t paraLen) -{ - uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN]; - uint32_t argc; - - if (ConvertCmdToParam(para, paraLen, argv, &argc) != CUSTOM_UTILS_SUCCESS) { - ppp_print_err("PPP MODE SWITCH Convert Command Failed\n"); - return ERRCODE_FAIL; - } - - if (argc != 1) { - ppp_print_err("PPP MODE SWITCH Set Parameter Failed argc %d\nUsage: AT^PPPMODE=AT|PPP\n", argc); - return ERRCODE_FAIL; - } - - errcode_t ret = ppp_test_switch_mode((char*)argv[0]); - if (ret == ERRCODE_SUCC) { - ppp_print_info("PPP MODE SWITCH: Successfully switched to %s mode\n", argv[0]); - } else { - ppp_print_err("PPP MODE SWITCH: Failed to switch to %s mode, error: %d\n", argv[0], ret); - } - - return ret; -} - /* PPP串口状态查询指令 */ static errcode_t at_ppp_status(uint8_t *para, uint32_t paraLen) { @@ -710,24 +686,6 @@ static errcode_t at_ppp_transparent(uint8_t *para, uint32_t paraLen) } } -/* PPP串口测试指令 */ -static errcode_t at_ppp_test(uint8_t *para, uint32_t paraLen) -{ - (void)para; - (void)paraLen; - - ppp_print_info("PPP TEST: Starting PPP serial test...\n"); - - errcode_t ret = ppp_test_uart_function(); - if (ret == ERRCODE_SUCC) { - ppp_print_info("PPP TEST: UART test completed successfully\n"); - } else { - ppp_print_err("PPP TEST: UART test failed, error: %d\n", ret); - } - - return ret; -} - /* PPP智能flush测试指令 */ static errcode_t at_ppp_flush(uint8_t *para, uint32_t paraLen) { @@ -969,22 +927,22 @@ static errcode_t at_ppp_show_runtime(uint8_t *para, uint32_t paraLen) ppp_print_info("PPP RUNTIME SHOW: Current runtime status:\n"); // 显示当前runtime状态 - ppp_print_info("\n=== Current Runtime Status ===\n"); - ppp_print_info("Power Status: %s\n", cat1_api_runtime_get_cat1_powerstat() ? "ON" : "OFF"); - ppp_print_info("Network Status: %s\n", cat1_api_runtime_get_cat1_networkstat() ? "CONNECTED" : "DISCONNECTED"); + ppp_print_info("\n=== Current Runtime Status ==="); + ppp_print_info("Power Status: %s", cat1_api_runtime_get_cat1_powerstat() ? "ON" : "OFF"); + ppp_print_info("Network Status: %s", cat1_api_runtime_get_cat1_networkstat() ? "CONNECTED" : "DISCONNECTED"); int signal = cat1_api_runtime_get_cat1_signal(); if (signal == 99) { - ppp_print_info("Signal Strength: No Signal (99)\n"); + ppp_print_info("Signal Strength: No Signal (99)"); } else { - ppp_print_info("Signal Strength: %d/31 (%s)\n", signal, + ppp_print_info("Signal Strength: %d/31 (%s)", signal, signal >= 20 ? "Excellent" : signal >= 15 ? "Good" : signal >= 10 ? "Fair" : signal >= 5 ? "Poor" : "Very Poor"); } - ppp_print_info("SIM Status: %s\n", cat1_api_runtime_get_cat1_simstat() ? "NORMAL" : "ERROR"); + ppp_print_info("SIM Status: %s", cat1_api_runtime_get_cat1_simstat() ? "NORMAL" : "ERROR"); uint8_t net_type = cat1_api_runtime_get_cat1_networktype(); const char* net_type_str = "Unknown"; @@ -997,21 +955,68 @@ static errcode_t at_ppp_show_runtime(uint8_t *para, uint32_t paraLen) case 5: net_type_str = "Registered (Roaming)"; break; default: net_type_str = "Invalid"; break; } - ppp_print_info("Network Type: %d (%s)\n", net_type, net_type_str); + ppp_print_info("Network Type: %d (%s)", net_type, net_type_str); char* operator = cat1_api_runtime_get_cat1_operator(); - ppp_print_info("Operator: %s\n", (operator && strlen(operator) > 0) ? operator : "Unknown"); + ppp_print_info("Operator: %s", (operator && strlen(operator) > 0) ? operator : "Unknown"); char* imei = cat1_api_runtime_get_cat1_imei(); - ppp_print_info("IMEI: %s\n", (imei && strlen(imei) > 0) ? imei : "Unknown"); + ppp_print_info("IMEI: %s", (imei && strlen(imei) > 0) ? imei : "Unknown"); char* iccid = cat1_api_runtime_get_cat1_iccid(); - ppp_print_info("ICCID: %s\n", (iccid && strlen(iccid) > 0) ? iccid : "Unknown"); + ppp_print_info("ICCID: %s", (iccid && strlen(iccid) > 0) ? iccid : "Unknown"); char* version = cat1_api_runtime_get_cat1_modemver(); - ppp_print_info("Modem Version: %s\n", (version && strlen(version) > 0) ? version : "Unknown"); - - ppp_print_info("===============================\n"); + ppp_print_info("Modem Version: %s", (version && strlen(version) > 0) ? version : "Unknown"); + + ppp_print_info("==============================="); + + // 显示PPP输出统计信息 + ppp_lwip_output_stats_t ppp_stats; + if (ppp_lwip_get_output_stats(&ppp_stats) == PPP_ERR_OK) { + ppp_print_info("\n=== PPP Output Statistics ==="); + ppp_print_info("Total Output Packets: %llu", ppp_stats.total_packets); + ppp_print_info("Total Output Bytes: %llu", ppp_stats.total_bytes); + ppp_print_info("LCP Packets: %u", ppp_stats.lcp_packets); + ppp_print_info("IPCP Packets: %u", ppp_stats.ipcp_packets); + ppp_print_info("IP Packets: %u", ppp_stats.ip_packets); + ppp_print_info("Other Protocol Packets: %u", ppp_stats.other_packets); + ppp_print_info("Failed Sends: %u", ppp_stats.failed_sends); + + // 计算PPP输出统计的运行时间和速率 + uint32_t current_time = ppp_stats.last_packet_time; + if (current_time == 0) { + // 如果没有最后包时间,使用当前时间的简单估算 + current_time = ppp_stats.start_time + 10000; // 假设运行了10秒 + } + uint32_t ppp_elapsed_ms = current_time - ppp_stats.start_time; + uint32_t ppp_elapsed_sec = ppp_elapsed_ms / 1000; + + if (ppp_elapsed_sec > 0) { + ppp_print_info("PPP Stats Duration: %u seconds", ppp_elapsed_sec); + } + + if (ppp_elapsed_ms > 0 && ppp_stats.total_bytes > 0) { + uint64_t ppp_throughput_bps = (ppp_stats.total_bytes * 1000) / ppp_elapsed_ms; + ppp_print_info("PPP Output Throughput: %llu bytes/s", ppp_throughput_bps); + + float ppp_packet_rate = (float)ppp_stats.total_packets * 1000 / ppp_elapsed_ms; + ppp_print_info("PPP Output Packet Rate: %.1f packets/s", ppp_packet_rate); + } + + // 计算成功率 + uint64_t total_attempts = ppp_stats.total_packets + ppp_stats.failed_sends; + if (total_attempts > 0) { + float success_rate = (float)ppp_stats.total_packets / total_attempts * 100; + ppp_print_info("PPP Output Success Rate: %.1f%%", success_rate); + } + + ppp_print_info("============================="); + } else { + ppp_print_info("\n=== PPP Output Statistics ==="); + ppp_print_info("Failed to get PPP output statistics"); + ppp_print_info("============================="); + } ppp_lwip_print_discard_stats(); @@ -1482,7 +1487,7 @@ static errcode_t at_ppp_test_uart_at_mode(uint8_t *para, uint32_t paraLen) ppp_print_info("Sending AT command for UART test...\n"); - errcode_t ret = ppp_test_execute_at_command("AT", response, sizeof(response), &response_len, 5000); + errcode_t ret = ppp_execute_at_command("AT", response, sizeof(response), &response_len, 5000); if (ret == ERRCODE_SUCC) { ppp_print_info("AT mode UART test SUCCESS!\n"); ppp_print_info("Response (%d bytes): %s\n", response_len, response); @@ -1720,24 +1725,25 @@ static errcode_t at_ppp_debug_reset_level(uint8_t *para, uint32_t paraLen) /** * @brief AT^PPPTCPPERF - PPP TCP性能测试 - * @param para 参数: 服务器地址,端口,连接数,测试时间 + * @param para 参数: 服务器地址,端口,连接数,测试时间[,接收超时(ms)] * @param paraLen 参数长度 */ static errcode_t at_ppp_tcp_performance_test(uint8_t *para, uint32_t paraLen) { if (!para || paraLen == 0) { PRINT("[PPP_ERR]PPP TCP PERF: Missing parameters\r\n"); - PRINT("[PPP_INFO]Usage: AT^PPPTCPPERF=,,,