From e4d265e24ca2fb3ef33d600a93651a2300711c91 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Sun, 21 Sep 2025 11:37:20 +0000 Subject: [PATCH] Merge #2360 into sdk650pathc0423 from refs/changes/2360/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/2360/head: (3 commits squashed) - ota文件路径采用统一宏 - Merge branch 'sdk650pathc0423' of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into sdk650pathc0423 - Merge branch 'sdk650pathc0423' of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into sdk650pathc0423 Signed-off-by: 罗正 <1732036298@qq.com> Merged-by: 罗正 <1732036298@qq.com> CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/2360 --- code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c index c26defe67..9afb1cda1 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c @@ -1,6 +1,7 @@ #include "ln_api.h" #include #include +#include "upg_common_porting.h" /* 使用统一的 UPG_FILE_NAME 路径宏 */ #include #include @@ -153,7 +154,7 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path, } // 打开文件准备写入 - FILE *fd = fopen(save_path, "wb"); + FILE *fd = fopen(save_path, "wb+"); if (!fd) { printf("[OTA] fopen failed for %s:\n", save_path); @@ -194,7 +195,7 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path, do { ret = HttpClientRecvResponse(&client, &client_data); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_ota_download_flow_http", "ret = %d", ret); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_ota_download_flow_http:%d", ret); if (ret == HTTP_SUCCESS || ret == HTTP_EAGAIN) { // 处理接收到的数据块 @@ -293,13 +294,15 @@ uint32_t ln_ota_download_flow_http(const char *device_id, printf("[OTA] no cached task to download, please GET_TASK first\n"); return ERRCODE_FAIL; } - size_t sp_cap = strlen(LN_OTA_SAVE_DIR) + 1 + strlen(g_ln_last_target_version) + strlen(".fwpkg") + 1; + /* 固定保存到统一升级包路径 */ + size_t sp_cap = strlen(UPG_FILE_NAME) + 1; + printf("UPG_FILE_NAME:%s\n",UPG_FILE_NAME); char *save_path = (char *)malloc(sp_cap); if (!save_path) { return ERRCODE_FAIL; } - snprintf(save_path, sp_cap, LN_OTA_SAVE_DIR "/%s.fwpkg", g_ln_last_target_version); + (void)snprintf(save_path, sp_cap, "%s", UPG_FILE_NAME); if (g_ln_last_saved_path) { free(g_ln_last_saved_path); -- 2.17.1