Merge branch 'sdk650pathc0423' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0... 2383/1 2383/head 2384/target/1
authorCaisking <Casiking@zhihuishixun.com>
Wed, 24 Sep 2025 08:53:00 +0000 (16:53 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Wed, 24 Sep 2025 08:53:00 +0000 (16:53 +0800)
1  2 
code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h

@@@ -1157,81 -1151,72 +1157,147 @@@ static uint32_t ln_schedule_reminder_cf
      return ERRCODE_SUCC;
  }
  
 +/**
 + * @brief AT^LN_MEMORY_INFO - 查看系统内存信息
 + * @param para 参数字符串(未使用)
 + * @param paraLen 参数长度(未使用)
 + * @param strCommonCmd 命令字符串(未使用)
 + * @return uint32_t 错误码
 + * 
 + * 功能:显示系统内存使用情况
 + * 用法:AT^LN_MEMORY_INFO
 + */
 +static uint32_t ln_memory_info_at(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 +{
 +    VAD_UNUSED(para);
 +    VAD_UNUSED(paraLen);
 +    VAD_UNUSED(strCommonCmd);
 +    
 +    printf("\r\n=== System Memory Information ===\r\n");
 +    
 +    // 直接使用C接口获取系统内存信息
 +    const char* memoryInfo = get_system_memory_info();
 +    printf("%s", memoryInfo);
 +    
 +    printf("\r\nMemory check completed.\r\n");
 +    return ERRCODE_SUCC;
 +}
 +
 +/**
 + * @brief AT^LN_FOLDER_SIZE=<path> - 查看指定文件夹大小
 + * @param para 参数字符串(文件夹路径)
 + * @param paraLen 参数长度
 + * @param strCommonCmd 命令字符串(未使用)
 + * @return uint32_t 错误码
 + * 
 + * 功能:显示指定文件夹的大小
 + * 用法:AT^LN_FOLDER_SIZE=/user/music/
 + *       AT^LN_FOLDER_SIZE(使用默认路径/user/)
 + */
 +static uint32_t ln_folder_size_at(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 +{
 +    char folder_path[256] = "/user/";  // 默认路径
 +    
 +    if (para != NULL && paraLen > 0) {
 +        // 解析参数获取文件夹路径
 +        uint8_t argv[LN_MAX_ARGC][LN_MAX_ARGV_LEN] = {0};
 +        uint32_t argc = 0;
 +        (void)ConvertCmdToParam(para, paraLen, argv, &argc);
 +        
 +        if (argc >= 1) {
 +            strncpy(folder_path, (char*)argv[0], sizeof(folder_path) - 1);
 +            folder_path[sizeof(folder_path) - 1] = '\0';
 +        }
 +    }
 +    
 +    printf("\r\n=== Folder Size Information ===\r\n");
 +    printf("Target Path: %s\r\n", folder_path);
 +    
 +    // 检查路径是否存在
 +    struct stat path_stat;
 +    if (stat(folder_path, &path_stat) != 0) {
 +        printf("Error: Path does not exist or cannot be accessed\r\n");
 +        return ERRCODE_FAIL;
 +    }
 +    
 +    if (!S_ISDIR(path_stat.st_mode)) {
 +        printf("Error: Path is not a directory\r\n");
 +        return ERRCODE_FAIL;
 +    }
 +    
 +    // 直接使用C接口获取文件夹大小
 +    uint64_t folder_size = get_folder_size(folder_path);
 +    
 +    printf("Folder Size: %llu bytes (%llu KB, %llu MB)\r\n", 
 +           folder_size, folder_size / 1024, folder_size / (1024 * 1024));
 +    
 +    printf("Folder size check completed.\r\n");
+ /* AT^LN_CHARACTER_CFG[=characterName,eyesShape,hairColor,eyesColor,hairStyle,screenImageAsEmoji] */
+ static uint32_t ln_character_config_change_at(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+ {
+     VAD_UNUSED(strCommonCmd);
+     const char *deviceId = uapi_ln_get_device_id();
+     const char *id = (deviceId && deviceId[0]) ? deviceId : "DEVICE_LOCAL";
+ 
+     /* 默认值(与示例一致) */
+     const char *characterId = "char_at";
+     const char *characterName = "小艾";
+     const char *eyesShape = "upturned-eyes";
+     const char *hairColor = "blue";
+     const char *eyesColor = "green";
+     const char *hairStyle = "side-parted-comma";
+     const char *screenImage = "https://example.com/new_avatar.bin";
+     int screenImageAsEmoji = 1; // true
+ 
+     if (para != NULL && paraLen > 0) {
+         uint8_t argv[LN_MAX_ARGC][LN_MAX_ARGV_LEN] = {0};
+         uint32_t argc = 0;
+         (void)ConvertCmdToParam(para, paraLen, argv, &argc);
+         if (argc >= 1 && argv[0][0]) { characterName = (const char*)argv[0]; }
+         if (argc >= 2 && argv[1][0]) { eyesShape = (const char*)argv[1]; }
+         if (argc >= 3 && argv[2][0]) { hairColor = (const char*)argv[2]; }
+         if (argc >= 4 && argv[3][0]) { eyesColor = (const char*)argv[3]; }
+         if (argc >= 5 && argv[4][0]) { hairStyle = (const char*)argv[4]; }
+         if (argc >= 6 && argv[5][0]) { screenImageAsEmoji = atoi((char*)argv[5]) ? 1 : 0; }
+     }
+ 
+     char *json = (char*)malloc(1024);
+     if (json == NULL) {
+         printf("[LN][CHAR_CFG] OOM\n");
+         return ERRCODE_FAIL;
+     }
+     int n = snprintf(json, 1024,
+         "{\n"
+         "  \"deviceId\": \"%s\",\n"
+         "  \"timestamp\": %u,\n"
+         "  \"messageId\": \"at_msg\",\n"
+         "  \"command\": \"CharacterConfigChange\",\n"
+         "  \"data\": {\n"
+         "    \"characterId\": \"%s\",\n"
+         "    \"characterName\": \"%s\",\n"
+         "    \"characterAvatar\": {\n"
+         "      \"eyesShape\": \"%s\",\n"
+         "      \"hairColor\": \"%s\",\n"
+         "      \"eyesColor\": \"%s\",\n"
+         "      \"hairStyle\": \"%s\",\n"
+         "      \"screenImage\": \"%s\",\n"
+         "      \"screenImageAsEmoji\": %s\n"
+         "    }\n"
+         "  }\n"
+         "}\n",
+         id, 0U, characterId, characterName, eyesShape, hairColor, eyesColor, hairStyle, screenImage,
+         screenImageAsEmoji ? "true" : "false");
+     if (n <= 0 || n >= 1024) {
+         free(json);
+         printf("[LN][CHAR_CFG] build json failed\n");
+         return ERRCODE_FAIL;
+     }
+ 
+     ln_parse_character_config(json, n);
+     printf("\r\n[LN][CHAR_CFG] ok. name=%s eyesShape=%s hairColor=%s eyesColor=%s\n",
+            characterName, eyesShape, hairColor, eyesColor);
+ 
+     free(json);
      return ERRCODE_SUCC;
  }
  
@@@ -1287,10 -1272,7 +1353,12 @@@ static const at_cmd_table_t g_ln_api_cm
      {(char *)"AT^LN_UI_OTA_PROGRESS", ln_ui_ota_progress_at, (char *)"推送OTA升级进度: AT^LN_UI_OTA_PROGRESS=100"},
      {(char *)"AT^LN_SCHEDULE_REMINDER", ln_schedule_reminder_at, (char *)"日程提醒: AT^LN_SCHEDULE_REMINDER[=scheduleName,reminderContent]"},
      {(char *)"AT^LN_SCHEDULE_REMINDER_CFG", ln_schedule_reminder_cfg_at, (char *)"日程提醒配置: AT^LN_SCHEDULE_REMINDER_CFG[=scheduleName]"},
 +    
 +    /* 内存查看相关AT命令 */
 +    {(char *)"AT^LN_MEMORY_INFO", ln_memory_info_at, (char *)"查看系统内存信息: AT^LN_MEMORY_INFO"},
 +    {(char *)"AT^LN_FOLDER_SIZE", ln_folder_size_at, (char *)"查看文件夹大小: AT^LN_FOLDER_SIZE[=/path/to/folder]"},
++    
+     {(char *)"AT^LN_CHARACTER_CFG", ln_character_config_change_at, (char *)"角色配置更改: AT^LN_CHARACTER_CFG[=name,eyesShape,hairColor,eyesColor,hairStyle,screenImageAsEmoji]"},
  };
  
  
@@@ -82,28 -79,26 +82,48 @@@ void push_task_reminder_notification(co
      SendMsgToUIService(HAND_TASK_REMINDER_NOTIFY, 0,(void *)scheduleName, (int32_t)strlen(scheduleName));
  }
  
 +// 内存管理相关C接口实现
 +static std::string g_memory_info_cache;
 +
 +const char* get_system_memory_info(void)
 +{
 +    OHOS::MemoryManager* memoryManager = OHOS::MemoryManager::GetInstance();
 +    if (memoryManager == NULL) {
 +        return "Error: Failed to get MemoryManager instance";
 +    }
 +    
 +    g_memory_info_cache = memoryManager->GetSystemMemoryInfo();
 +    return g_memory_info_cache.c_str();
 +}
 +
 +uint64_t get_folder_size(const char *folder_path)
 +{
 +    OHOS::MemoryManager* memoryManager = OHOS::MemoryManager::GetInstance();
 +    if (memoryManager == NULL) {
 +        return 0;
 +    }
 +    
 +    return memoryManager->GetFolderSize(folder_path);
+ // 推送角色配置更改通知(简洁载荷)
+ void push_character_config_change_notification(const char* characterId,
+     const char *characterName,
+     const char *eyesShape,
+     const char *hairColor,
+     const char *eyesColor,
+     const char *hairStyle,
+     int screenImageAsEmoji)
+ {
+     // 组装紧凑 payload: 使用分隔符拼装,UI 侧再拆分(或改用结构体)
+     char payload[512] = {0};
+     const char* id = characterId? characterId:"";
+     const char *n = characterName ? characterName : "";
+     const char *es = eyesShape ? eyesShape : "";
+     const char *hc = hairColor ? hairColor : "";
+     const char *ec = eyesColor ? eyesColor : "";
+     const char *hs = hairStyle ? hairStyle : "";
+     (void)snprintf(payload, sizeof(payload) - 1, "%s|%s|%s|%s|%s|%s|%d", id,n, es, hc, ec, hs, screenImageAsEmoji ? 1 : 0);
+ 
+     SendMsgToUIService(HAND_CHARACTER_CONFIG_CHANGE_NOTIFY, 0, (void *)payload, (int32_t)strlen(payload));
  }
  
  #ifdef __cplusplus
@@@ -44,13 -42,18 +44,23 @@@ void push_ota_progress(int progress)
  void do_restore_factory_setting(void);
  // 推送日程提醒通知
  void push_schedule_reminder_notification(const char *title, const char *content);
+ 
  // 推送任务提醒
  void push_task_reminder_notification(const char *scheduleName);
 +
 +// 内存管理相关C接口
 +const char* get_system_memory_info(void);
 +uint64_t get_folder_size(const char *folder_path);
 +
+ //推送角色(配置更改)/切换通知
+ void push_character_config_change_notification(
+                                               const char* characterId,
+                                               const char *characterName,
+                                               const char *eyesShape,
+                                               const char *hairColor,
+                                               const char *eyesColor,
+                                               const char *hairStyle,
+                                               int screenImageAsEmoji);
  #ifdef __cplusplus
  }
  #endif