From 3e5e34880133b9a63c00f436315d3575a371d0f9 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Tue, 16 Sep 2025 11:08:45 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E8=BD=BD=E6=98=9F?= =?utf8?q?=E5=8E=86=E6=96=87=E4=BB=B6=E6=97=B6cat1=E4=BF=9D=E6=B4=BB?= =?utf8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../services/gnss/src/gnss_http_server.c | 60 ++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/code/sdk/zhihui/services/gnss/src/gnss_http_server.c b/code/sdk/zhihui/services/gnss/src/gnss_http_server.c index cc1c684fa..6efcbd393 100644 --- a/code/sdk/zhihui/services/gnss/src/gnss_http_server.c +++ b/code/sdk/zhihui/services/gnss/src/gnss_http_server.c @@ -29,6 +29,10 @@ // code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/http/include/httpclient.h #include +#ifdef SUPPORT_CAT1_SERVICE +#include "cat1_porting.h" +#endif + #define PGNSS_DATA_PATH "/user/userdata/gnss" // 全局变量用于存储接收到的数据 @@ -158,6 +162,14 @@ static void agnss_download_result_handler(const char *filename, HTTPC_RESULT res // HTTP请求失败,设置失败状态 g_download_status = -1; printf("HTTP request failed (result: %d, code: %d), status: -1\n", result, response_code); + + // HTTP请求失败,清理CAT1资源 +#ifdef SUPPORT_CAT1_SERVICE + cat1_api_remove_cat1_vote(); + cat1_api_keep_wakeup(0); + cat1_api_wakeup_cat1(0); + cat1_api_disable_cat1_cmd(0); +#endif } } } @@ -1226,6 +1238,13 @@ static void agnss_process_complete_response(void) // 重置处理计数器 g_processing_count = 0; + + #ifdef SUPPORT_CAT1_SERVICE + cat1_api_remove_cat1_vote(); + cat1_api_keep_wakeup(0); + cat1_api_wakeup_cat1(0); + cat1_api_disable_cat1_cmd(0); + #endif // 验证下载的文件 verify_downloaded_files(selected_timestamp); @@ -1366,11 +1385,12 @@ int download_agnss_files(void) printf("Starting AGNSS download, set download flag, status: 0 (连接中)\n"); //通讯开始,唤醒cat1 +#ifdef SUPPORT_CAT1_SERVICE cat1_api_add_cat1_vote(); cat1_api_wakeup_cat1(1); cat1_api_keep_wakeup(1); cat1_api_disable_cat1_cmd(1); - +#endif // 等待CAT1就绪 LOS_Msleep(1000); @@ -1458,12 +1478,19 @@ int download_agnss_files(void) g_download_status = -1; g_has_valid_json_data = 0; printf("Download failed, status: -1, cleared download flag\n"); + +#ifdef SUPPORT_CAT1_SERVICE + cat1_api_remove_cat1_vote(); + cat1_api_keep_wakeup(0); + cat1_api_wakeup_cat1(0); + cat1_api_disable_cat1_cmd(0); +#endif + } else { // 下载成功,清除标志位 g_has_valid_json_data = 0; printf("Download completed successfully, cleared download flag\n"); } - return 0; } @@ -1689,19 +1716,9 @@ static void gnss_http_server_recv_task(void const *arg) gnss_http_data_mail_t mail = {0}; uint32_t msgsize = sizeof(gnss_http_data_mail_t); - - // 添加任务保护计数器 - int task_loop_count = 0; - const int max_loop_count = 10000; // 防止无限循环 + while (1) { - task_loop_count++; - if (task_loop_count > max_loop_count) { - printf("Warning: Task loop count exceeded %d, resetting counter\n", max_loop_count); - task_loop_count = 0; - // 清理可能的内存泄漏 - cleanup_agnss_response_buffer(); - } ret = osal_msg_queue_read_copy(g_app_recv_queue, (void *)&mail, &msgsize, OSAL_MSGQ_WAIT_FOREVER); @@ -1715,7 +1732,6 @@ static void gnss_http_server_recv_task(void const *arg) // 数据接收完成,处理完整的响应 printf("AGNSS data reception completed, processing response...\n"); agnss_process_complete_response(); - task_loop_count = 0; // 重置计数器 } else { // 接收数据片段 printf("AGNSS data received via queue: %d bytes\n", mail.len); @@ -2135,6 +2151,14 @@ int gnss_start_agnss_download_simple(void) if (g_download_cancelled) { g_download_status = -1; printf("Status: -1 (下载已取消)\n"); + + // 下载取消,清理CAT1资源 +#ifdef SUPPORT_CAT1_SERVICE + cat1_api_remove_cat1_vote(); + cat1_api_keep_wakeup(0); + cat1_api_wakeup_cat1(0); + cat1_api_disable_cat1_cmd(0); +#endif return -1; } @@ -2143,6 +2167,14 @@ int gnss_start_agnss_download_simple(void) if (g_download_cancelled) { g_download_status = -1; printf("Status: -1 (下载已取消)\n"); + + // 下载取消,清理CAT1资源 +#ifdef SUPPORT_CAT1_SERVICE + cat1_api_remove_cat1_vote(); + cat1_api_keep_wakeup(0); + cat1_api_wakeup_cat1(0); + cat1_api_disable_cat1_cmd(0); +#endif return -1; } -- 2.17.1