Merge #2360 into sdk650pathc0423 from refs/changes/2360/head 2363/target/1 2364/target/1
author罗正 <1732036298@qq.com>
Sun, 21 Sep 2025 11:37:20 +0000 (11:37 +0000)
committer罗正 <1732036298@qq.com>
Sun, 21 Sep 2025 11:37:20 +0000 (11:37 +0000)
Code review from 罗正

* refs/changes/2360/head: (3 commits squashed)

  - ota文件路径采用统一宏

  - Merge branch &#39;sdk650pathc0423&#39; of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into sdk650pathc0423

  - Merge branch &#39;sdk650pathc0423&#39; of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into sdk650pathc0423

Signed-off-by: 罗正 <1732036298@qq.com>
Merged-by: 罗正 <1732036298@qq.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/2360
code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c

index c26defe..9afb1cd 100644 (file)
@@ -1,6 +1,7 @@
 #include "ln_api.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include "upg_common_porting.h"  /* 使用统一的 UPG_FILE_NAME 路径宏 */
 #include <string.h>
 #include <stdlib.h>
 
@@ -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);