改大ln_http_server_send_task线程的size大小,关闭cat1_ctl高频打印 2307/1 2307/head 2308/target/1
authorcheng <chengyf@zhihuishixun.com>
Thu, 18 Sep 2025 14:47:05 +0000 (22:47 +0800)
committercheng <chengyf@zhihuishixun.com>
Thu, 18 Sep 2025 14:47:05 +0000 (22:47 +0800)
code/sdk/zhihui/4g/cat1Service/Service/cat1_ctl.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api.h
code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c

index d968838..c519f7f 100644 (file)
@@ -329,7 +329,7 @@ void cat1_api_wakeup_cat1(uint8_t wakeup)
         }
         // wstp_cat1_print_dbg("wakeup Cat1! L30 high \r\n");
     }else{
-        cat1_print_warning("sleep cat1\n");
+        // cat1_print_warning("sleep cat1\n");
         if(en_value == uapi_gpio_get_output_val(en_pin))
         {
             if(en_value)
index fde8a8c..5777581 100644 (file)
@@ -12,6 +12,7 @@
 #include <soc_osal.h>
 #include "stdio.h"
 #include "audio_stream_player.h"
+#include "custom_utils.h"
 
 // 声明播放器消息处理函数
 extern void ln_story_player_simple_handle_message(int cmd, char *data, uint32_t len);
@@ -49,7 +50,7 @@ char *uapi_ln_get_device_id(void)
 /* 获取设备iccid:设备物联网卡号 */
 char *uapi_ln_get_device_iccid(void)
 {
-    g_device_iccid = ppp_api_update_imei();
+    g_device_iccid = cat1_api_runtime_get_cat1_iccid();
     return g_device_iccid;
 }
 /* 获取设备model */
@@ -61,7 +62,11 @@ char *uapi_ln_get_device_model(void)
 /* 获取设备固件版本version */
 char *uapi_ln_get_device_version(void)
 {
-    g_device_version = "1.3.107";
+    char version_buf[128] = {0};
+    uint32_t version_len = 128;
+    uapi_get_buildversion((uint8_t *)version_buf, version_len);
+    g_device_version = version_buf;
+    printf("g_device_version: %s\n", g_device_version);
     return g_device_version;
 }
 /* 获取设备token: 优先读本地缓存,判断过期,否则刷新 */
@@ -125,12 +130,24 @@ const char *uapi_ln_ota_get_saved_path(void)
 /* 获取语音对话流录音音频路径 */
 const char *uapi_ln_get_speechchat_audio_path(void)
 {
-    return "/user/leiniao/speech_chat_audio.mp3";
+    // 判断目录是否存在,不存在则创建
+    if (access(LN_DATA_PATH, F_OK) == -1)
+    {
+        uapi_create_folder(LN_DATA_PATH);
+    }
+    const char *path = LN_DATA_PATH "/speech_chat_audio.mp3";
+    return path;
 }
 /* 获取选择故事录音音频路径 */
 const char *uapi_ln_get_story_choose_audio_path(void)
 {
-    return "/user/leiniao/story_choose_audio.mp3";
+    // 判断目录是否存在,不存在则创建
+    if (access(LN_DATA_PATH, F_OK) == -1)
+    {
+        uapi_create_folder(LN_DATA_PATH);
+    }
+    const char *path = LN_DATA_PATH "/story_choose_audio.mp3";
+    return path;
 }
 
 void uapi_ln_audio_download_is_cancel(int status)
@@ -1193,7 +1210,7 @@ static void ln_http_server_recv_task(void const *arg)
 /* 创建雷鸟http发送队列 */
 static void create_ln_http_send_queue(void)
 {
-    if (osal_msg_queue_create("ln_http_send_queue", 24, &g_ln_send_queue,
+    if (osal_msg_queue_create("ln_http_send_queue", 32, &g_ln_send_queue,
                               0, sizeof(ln_http_data_mail_t)) != ERRCODE_SUCC)
     {
         printf("[ln][service] app create mail fail\n");
@@ -1203,7 +1220,7 @@ static void create_ln_http_send_queue(void)
 /* 创建雷鸟http接收队列 */
 static void create_ln_http_recv_queue(void)
 {
-    if (osal_msg_queue_create("ln_http_recv_queue", 24, &g_ln_recv_queue,
+    if (osal_msg_queue_create("ln_http_recv_queue", 32, &g_ln_recv_queue,
                               0, sizeof(ln_http_data_mail_t)) != ERRCODE_SUCC)
     {
         printf("[ln][service] app create mail fail\n");
@@ -1274,7 +1291,7 @@ errcode_t uapi_ln_http_server_init(void)
     ln_send_taskcfg.create_queue_handle = create_ln_http_send_queue;
     ln_send_taskcfg.attr.name = "ln_http_server_send_task";
     ln_send_taskcfg.attr.priority = osPriorityNormal;
-    ln_send_taskcfg.attr.stack_size = LN_HTTP_BOARD_TASK_SIZE;
+    ln_send_taskcfg.attr.stack_size = 0x4000;
     ln_send_taskcfg.func = ln_http_server_send_task;
     ln_send_taskcfg.use_mem = USE_EXTEND_MEM;
 
index ead3b03..2bbd55d 100644 (file)
@@ -52,9 +52,9 @@ typedef struct
 #define LN_EMOJI_REPORT_ALL_URL LN_BASE_URL LN_EMOJI_REPORT_ALL_PATH
 #define LN_SIGN_SECRET "vDdXVXgPUEUM6_piUjz5AEhMvYTSFzQdPaN-ogKnSus="
 /* OTA 包保存目录*/
-#define LN_OTA_SAVE_DIR "/user/update/update.fwpkg"
+#define LN_OTA_SAVE_DIR "/user/update"
 /* 用户数据保存目录 */
-#define LN_DATA_PATH          "/user/leiniao"
+#define LN_DATA_PATH    "/user/leiniao"
 
 #define LN_CLIENT_PREPARE_SIZE 2*1024
 #define TEST_MP3_DOWNLOAD 0 //测试下载mp3
index 0301cb7..738c46a 100644 (file)
@@ -121,6 +121,7 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
     HttpClientData client_data = {0};
     int ret = -1;
     size_t total_written = 0; // 已写入文件的总字节数
+    int last_percent = -1;    // 上次上报的进度百分比
 
     // 打开文件准备写入
     FILE *fd = fopen(save_path, "wb");
@@ -164,13 +165,11 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
     do
     {
         ret = HttpClientRecvResponse(&client, &client_data);
-        printf("[OTA] receive response: %d\n", ret);
         if (ret == HTTP_SUCCESS || ret == HTTP_EAGAIN)
         {
             // 处理接收到的数据块
             if (client_data.contentBlockLen > 0)
             {
-                printf("[OTA] received block: %d bytes\n", client_data.contentBlockLen);
                 // 写入文件(与http_download的写入逻辑一致)
                 size_t written = fwrite(client_data.responseBuf, 1,
                                         client_data.contentBlockLen, fd);
@@ -184,16 +183,19 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
                 total_written += written;
                 // 进度上报(使用已知的total_size计算)
                 int percent = (int)((total_written * 100) / total_size);
-                if (percent > 100)
-                    percent = 100; // 防止超过100%
-                char prog[128];
-                snprintf(prog, sizeof(prog),
-                         "{\"status\":%d,\"progress\":%d}",
-                         OTA_DOWNLOAD_STATUS_PROGRESS, percent);
-                do_ln_http_server_recv_data(LN_HTTP_RECV_OTA_DOWNLOAD_MSG,
-                                            prog, strlen(prog));
-                printf("[OTA] progress: %d%% (%zu/%d)\n",
-                       percent, total_written, total_size);
+                if (percent > 100) percent = 100; // 防止超过100%
+                if (percent != last_percent)
+                {
+                    last_percent = percent;
+                    char prog[64];
+                    int n = snprintf(prog, sizeof(prog),
+                                     "{\"status\":%d,\"progress\":%d}",
+                                     OTA_DOWNLOAD_STATUS_PROGRESS, percent);
+                    if (n > 0)
+                    {
+                        do_ln_http_server_recv_data(LN_HTTP_RECV_OTA_DOWNLOAD_MSG, prog, (uint32_t)n);
+                    }
+                }
 
                 // 检查是否超过预期总大小
                 if (total_written > (size_t)total_size)
@@ -204,6 +206,11 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
                     break;
                 }
             }
+            else
+            {
+                // 避免空块忙轮询占用CPU
+                LOS_Msleep(50);
+            }
         }
         else
         {
@@ -255,7 +262,7 @@ uint32_t ln_ota_download_flow_http(const char *device_id,
         return ERRCODE_FAIL;
     }
     char save_path[256];
-    snprintf(save_path, sizeof(save_path), LN_OTA_SAVE_DIR "/upgrade_%s.bin", g_ln_last_target_version);
+    snprintf(save_path, sizeof(save_path), LN_OTA_SAVE_DIR "/%s.fwpkg", g_ln_last_target_version);
     memset(g_ln_last_saved_path, 0, sizeof(g_ln_last_saved_path));
     strncpy(g_ln_last_saved_path, save_path, sizeof(g_ln_last_saved_path) - 1);
 
@@ -263,7 +270,7 @@ uint32_t ln_ota_download_flow_http(const char *device_id,
     int dres;
     if (g_ln_last_package_size > 0)
     {
-        dres = ln_download_file_to_path(g_ln_last_package_url, LN_OTA_SAVE_DIR, g_ln_last_package_size);
+        dres = ln_download_file_to_path(g_ln_last_package_url, save_path, g_ln_last_package_size);
     }
     if (dres != 0)
     {
@@ -275,7 +282,7 @@ uint32_t ln_ota_download_flow_http(const char *device_id,
     }
 
     char done[512];
-    int m = snprintf(done, sizeof(done), "{\"status\":%d,\"filePath\":\"%s\",\"md5\":\"%s\"}", 1, LN_OTA_SAVE_DIR, g_ln_last_package_md5);
+    int m = snprintf(done, sizeof(done), "{\"status\":%d,\"filePath\":\"%s\",\"md5\":\"%s\"}", 1, save_path, g_ln_last_package_md5);
     if (m > 0)
         do_ln_http_server_recv_data(LN_HTTP_RECV_OTA_DOWNLOAD_MSG, done, (uint32_t)m);
     return ERRCODE_SUCC;