#include "ln_api.h"
#include <stdio.h>
#include <stdlib.h>
+#include "upg_common_porting.h" /* 使用统一的 UPG_FILE_NAME 路径宏 */
#include <string.h>
#include <stdlib.h>
}
// 打开文件准备写入
- FILE *fd = fopen(save_path, "wb");
+ FILE *fd = fopen(save_path, "wb+");
if (!fd)
{
printf("[OTA] fopen failed for %s:\n", 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)
{
// 处理接收到的数据块
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);