// code/sdk/open_source/openharmony/foundation/ace/ace_engine_lite/modules/netstack/http/include/httpclient.h
#include <sys/stat.h>
+#ifdef SUPPORT_CAT1_SERVICE
+#include "cat1_porting.h"
+#endif
+
#define PGNSS_DATA_PATH "/user/userdata/gnss"
// 全局变量用于存储接收到的数据
// 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
}
}
}
// 重置处理计数器
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);
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);
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;
}
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);
// 数据接收完成,处理完整的响应
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);
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;
}
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;
}