雷鸟:cat1投票优化 2854/target/2 2856/1 2856/head
authorluozheng <1732036298@qq.com>
Thu, 4 Dec 2025 07:23:02 +0000 (15:23 +0800)
committerluozheng <1732036298@qq.com>
Thu, 4 Dec 2025 07:23:02 +0000 (15:23 +0800)
code/sdk/zhihui/leiniao/imsl_ln/ln_api_device_info.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_emoji.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_ota.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_schedule.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_speech_chat.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_choose.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_exit.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_finish.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_random.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_timeline_activities.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_token.c

index 4d147f9..8ba68f3 100644 (file)
@@ -485,7 +485,12 @@ uint32_t ln_device_get_character_http(const char *device_id,
 
     char *header_buf = (char *)malloc(512);
     if (!header_buf)
+    {
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
+    }
     int hdr = snprintf(header_buf, 512,
                        "deviceId: %s\r\n"
                        "deviceToken: %s\r\n"
@@ -494,6 +499,9 @@ uint32_t ln_device_get_character_http(const char *device_id,
     if (hdr <= 0)
     {
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -504,6 +512,10 @@ uint32_t ln_device_get_character_http(const char *device_id,
     if (prep != HTTP_SUCCESS)
     {
         printf("device getCharacter prepare failed %d\n", prep);
+        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -530,6 +542,9 @@ end:
     HttpClientUnprepare(&clientData);
     HttpClientClse(&client);
     free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+#endif
     return ERRCODE_SUCC;
 }
 
@@ -554,7 +569,12 @@ uint32_t ln_device_get_user_id_http(const char *device_id,
 
     char *header_buf2 = (char *)malloc(512);
     if (!header_buf2)
+    {
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
+    }
     int hdr = snprintf(header_buf2, 512,
                        "deviceId: %s\r\n"
                        "deviceToken: %s\r\n"
@@ -563,6 +583,9 @@ uint32_t ln_device_get_user_id_http(const char *device_id,
     if (hdr <= 0)
     {
         free(header_buf2);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf2);
@@ -573,6 +596,10 @@ uint32_t ln_device_get_user_id_http(const char *device_id,
     if (prep != HTTP_SUCCESS)
     {
         printf("device getUserId prepare failed %d\n", prep);
+        free(header_buf2);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -636,6 +663,9 @@ end:
     HttpClientUnprepare(&clientData);
     HttpClientClse(&client);
     free(header_buf2);
+#ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+#endif
     return ERRCODE_SUCC;
 }
 
@@ -663,6 +693,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
     if (!header_buf)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CHAT_STAMINA] malloc failed for header_buf");
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     int hdr = snprintf(header_buf, 512,
@@ -674,6 +707,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
     {
         free(header_buf);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CHAT_STAMINA] snprintf failed for header_buf");
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -684,6 +720,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CHAT_STAMINA] prepare failed: %d", prep);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -694,6 +733,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
         HttpClientUnprepare(&clientData);
         HttpClientClse(&client);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -705,6 +747,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
         HttpClientUnprepare(&clientData);
         HttpClientClse(&client);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -714,6 +759,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
         HttpClientUnprepare(&clientData);
         HttpClientClse(&client);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     memcpy(json_text, clientData.responseBuf, (size_t)body_len);
@@ -735,6 +783,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
         HttpClientUnprepare(&clientData);
         HttpClientClse(&client);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -751,6 +802,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
         HttpClientUnprepare(&clientData);
         HttpClientClse(&client);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -763,6 +817,9 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
         HttpClientUnprepare(&clientData);
         HttpClientClse(&client);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -792,5 +849,8 @@ uint32_t ln_device_get_chat_stamina_http(const char *device_id, const char *devi
     HttpClientUnprepare(&clientData);
     HttpClientClse(&client);
     free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+#endif
     return ERRCODE_SUCC;
 }
\ No newline at end of file
index 227ff2e..3beb938 100644 (file)
@@ -1042,6 +1042,9 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
     if (!header_buf)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[EMOJI_REPORT_STATUS] malloc header_buf failed");
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     int hdr = snprintf(header_buf, 512,
@@ -1053,6 +1056,9 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
     {
         free(header_buf);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[EMOJI_REPORT_STATUS] build header failed");
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -1062,6 +1068,10 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
     if (!root)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[EMOJI_REPORT_STATUS] create root object failed");
+        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     cJSON_AddStringToObject(root, "characterId", character_id);
@@ -1074,6 +1084,10 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
     if (!body)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[EMOJI_REPORT_STATUS] print unformatted failed");
+        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -1083,6 +1097,9 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
         free(body);
         free(header_buf);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[EMOJI_REPORT_STATUS] prepare auto failed");
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     clientData.postBuf = body;
@@ -1104,6 +1121,9 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
         HttpClientUnprepare(&clientData);
         free(header_buf);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[EMOJI_REPORT_STATUS] request failed");
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -1114,6 +1134,9 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
         HttpClientUnprepare(&clientData);
         free(header_buf);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[EMOJI_REPORT_STATUS] response code not 200");
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     if (clientData.responseBuf && clientData.responseBufLen > 0)
@@ -1141,6 +1164,9 @@ static uint32_t ln_emoji_report_status_http(const char *device_id,
     free(body);
     HttpClientUnprepare(&clientData);
     free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+#endif
     return ERRCODE_SUCC;
 }
 /* 7.2 上报设备所有表情组状态 */
@@ -1150,7 +1176,12 @@ static uint32_t ln_emoji_report_all_http(const char *device_id,
                                   int group_count)
 {
     if (!device_id || !device_token || (!groups && group_count > 0) || group_count < 0)
+    {
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
+    }
 
 #ifdef SUPPORT_CAT1_SERVICE
     cat1_api_add_cat1_vote();
@@ -1166,7 +1197,12 @@ static uint32_t ln_emoji_report_all_http(const char *device_id,
     /* 直接构造自定义请求头,生命周期贯穿整个请求,结束后再释放 */
     char *header_buf = (char *)malloc(512);
     if (!header_buf)
+    {
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
+    }
     int hdr = snprintf(header_buf, 512,
                        "deviceId: %s\r\n"
                        "deviceToken: %s\r\n"
@@ -1175,6 +1211,9 @@ static uint32_t ln_emoji_report_all_http(const char *device_id,
     if (hdr <= 0)
     {
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -1182,11 +1221,21 @@ static uint32_t ln_emoji_report_all_http(const char *device_id,
     /* 组装 JSON 数组 */
     cJSON *root = cJSON_CreateObject();
     if (!root)
+    {
+        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
+    }
     cJSON *arr = cJSON_CreateArray();
     if (!arr)
     {
         cJSON_Delete(root);
+        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     for (int i = 0; i < group_count; ++i)
@@ -1206,7 +1255,13 @@ static uint32_t ln_emoji_report_all_http(const char *device_id,
     char *body = cJSON_PrintUnformatted(root);
     cJSON_Delete(root);
     if (!body)
+    {
+        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
+    }
 
     HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, LN_CLIENT_PREPARE_SIZE * 2);
     if (prep != HTTP_SUCCESS)
index e614ecd..b42af78 100644 (file)
@@ -523,7 +523,12 @@ uint32_t ln_ota_get_task_http(const char *device_id,
                      (uapi_ln_get_device_version() ? strlen(uapi_ln_get_device_version()) : 5);
     char *header_buf = (char *)malloc(hdr_cap + 128);
     if (!header_buf)
+    {
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
+    }
     int hdr = snprintf(header_buf, hdr_cap + 128,
                        "deviceId: %s\r\n"
                        "deviceToken: %s\r\n"
@@ -536,6 +541,9 @@ uint32_t ln_ota_get_task_http(const char *device_id,
     if (hdr <= 0)
     {
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -544,6 +552,10 @@ uint32_t ln_ota_get_task_http(const char *device_id,
     if (prep != HTTP_SUCCESS)
     {
         printf("[OTA] getTask prepare failed %d\n", prep);
+        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -554,6 +566,9 @@ uint32_t ln_ota_get_task_http(const char *device_id,
     {
         HttpClientUnprepare(&clientData);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
     int ulen = snprintf(url_with_params, url_cap,
@@ -564,6 +579,9 @@ uint32_t ln_ota_get_task_http(const char *device_id,
         HttpClientUnprepare(&clientData);
         free(header_buf);
         free(url_with_params);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
         return ERRCODE_FAIL;
     }
 
@@ -601,6 +619,9 @@ end:
         free(header_buf);
     if (url_with_params)
         free(url_with_params);
+#ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+#endif
     return ERRCODE_SUCC;
 }
 
@@ -659,6 +680,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
         if (resume_offset >= (long long)total_size)
         {
             printf("[OTA] local file already complete: %lld >= %d\n", resume_offset, total_size);
+            #ifdef SUPPORT_CAT1_SERVICE
+            cat1_api_remove_cat1_vote();
+            #endif
+            uapi_ln_remove_vote();
             return 0; // 视为已完成
         }
     }
@@ -668,6 +693,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
     if (!fd)
     {
         printf("[OTA] fopen failed for %s:\n", save_path);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
+        uapi_ln_remove_vote();
         return -1;
     }
 
@@ -676,6 +705,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
     {
         printf("[OTA] range prepare failed: %d\n", prep);
         fclose(fd);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
+        uapi_ln_remove_vote();
         return -1;
     }
 
@@ -688,6 +721,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
         {
             HttpClientUnprepare(&client_data);
             fclose(fd);
+#ifdef SUPPORT_CAT1_SERVICE
+            cat1_api_remove_cat1_vote();
+#endif
+            uapi_ln_remove_vote();
             return -1;
         }
         int hdr = snprintf(header_buf, 128, "Range: bytes=%lld-\r\n", resume_offset);
@@ -696,6 +733,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
             free(header_buf);
             HttpClientUnprepare(&client_data);
             fclose(fd);
+#ifdef SUPPORT_CAT1_SERVICE
+            cat1_api_remove_cat1_vote();
+#endif
+            uapi_ln_remove_vote();
             return -1;
         }
         HttpClientSetCustomHeader(&client, header_buf);
@@ -709,6 +750,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
         if (header_buf) free(header_buf);
         fclose(fd);
         HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
+        uapi_ln_remove_vote();
         return ret;
     }
 
@@ -721,6 +766,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
         HttpClientClse(&client);
         fclose(fd);
         HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
+        uapi_ln_remove_vote();
         return ret;
     }
 
@@ -734,6 +783,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
         HttpClientClse(&client);
         fclose(fd);
         HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
+        uapi_ln_remove_vote();
         return -1;
     }
 
@@ -749,6 +802,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
             if (header_buf) free(header_buf);
             HttpClientClse(&client);
             HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+            cat1_api_remove_cat1_vote();
+#endif
+            uapi_ln_remove_vote();
             return -1;
         }
         resume_offset = 0;
@@ -767,6 +824,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
             fclose(fd);
             HttpClientClse(&client);
             HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+            cat1_api_remove_cat1_vote();
+#endif
+            uapi_ln_remove_vote();
             return -1;
         }
         total_written += written;
@@ -801,6 +862,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
                     fclose(fd);
                     HttpClientClse(&client);
                     HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+                    cat1_api_remove_cat1_vote();
+#endif
+                    uapi_ln_remove_vote();
                     return -1;
                 }
                 total_written += written;
@@ -824,6 +889,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
                     fclose(fd);
                     HttpClientClse(&client);
                     HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+                    cat1_api_remove_cat1_vote();
+#endif
+                    uapi_ln_remove_vote();
                     return -1;
                 }
             }
@@ -860,6 +929,10 @@ static int ln_download_file_to_path(const char *full_url, const char *save_path,
     fclose(fd);
     HttpClientClse(&client);
     HttpClientUnprepare(&client_data);
+#ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+#endif
+    uapi_ln_remove_vote();
 
     printf("[OTA] download process finished\n");
 
index ed8b78e..710d231 100644 (file)
@@ -107,7 +107,7 @@ void ln_parse_schedule_reminder(const char *json_buf, int json_len)
 {
     if (!json_buf || json_len <= 0)
     {
-        printf("[SCHEDULE_REMINDER] invalid json input\n");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER] invalid json input\n");
         return;
     }
 
@@ -122,7 +122,7 @@ void ln_parse_schedule_reminder(const char *json_buf, int json_len)
     cJSON *root = cJSON_Parse(text);
     if (!root)
     {
-        printf("[SCHEDULE_REMINDER] json parse failed\n");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER] json parse failed\n");
         free(text);
         return;
     }
@@ -131,7 +131,7 @@ void ln_parse_schedule_reminder(const char *json_buf, int json_len)
     cJSON *errorCode = cJSON_GetObjectItem(root, "errorCode");
     if (errorCode && !cJSON_IsNull(errorCode))
     {
-        printf("[SCHEDULE_REMINDER] server error: %s\n",
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER] server error: %s\n",
                cJSON_IsString(errorCode) ? errorCode->valuestring : "unknown");
         cJSON_Delete(root);
         free(text);
@@ -142,7 +142,7 @@ void ln_parse_schedule_reminder(const char *json_buf, int json_len)
     cJSON *data = cJSON_GetObjectItem(root, "data");
     if (!data || !cJSON_IsObject(data))
     {
-        printf("[SCHEDULE_REMINDER] no data object\n");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER] no data object\n");
         cJSON_Delete(root);
         free(text);
         return;
@@ -176,14 +176,14 @@ void ln_parse_schedule_reminder(const char *json_buf, int json_len)
     g_schedule_reminder.enableVibration = (enableVibration && cJSON_IsNumber(enableVibration)) ? enableVibration->valueint : 0;
 
     // 打印解析结果
-    printf("[SCHEDULE_REMINDER] parsed successfully:\n");
-    printf("  scheduleId: %d\n", g_schedule_reminder.scheduleId);
-    printf("  deviceId: %s\n", g_schedule_reminder.deviceId ? g_schedule_reminder.deviceId : "");
-    printf("  scheduleName: %s\n", g_schedule_reminder.scheduleName ? g_schedule_reminder.scheduleName : "");
-    printf("  reminderContent: %s\n", g_schedule_reminder.reminderContent ? g_schedule_reminder.reminderContent : "");
-    printf("  reminderAudioUrl: %s\n", g_schedule_reminder.reminderAudioUrl ? g_schedule_reminder.reminderAudioUrl : "");
-    printf("  enableVoice: %d\n", g_schedule_reminder.enableVoice);
-    printf("  enableVibration: %d\n", g_schedule_reminder.enableVibration);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER] parsed successfully:\n");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  scheduleId: %d\n", g_schedule_reminder.scheduleId);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  deviceId: %s\n", g_schedule_reminder.deviceId ? g_schedule_reminder.deviceId : "");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  scheduleName: %s\n", g_schedule_reminder.scheduleName ? g_schedule_reminder.scheduleName : "");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  reminderContent: %s\n", g_schedule_reminder.reminderContent ? g_schedule_reminder.reminderContent : "");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  reminderAudioUrl: %s\n", g_schedule_reminder.reminderAudioUrl ? g_schedule_reminder.reminderAudioUrl : "");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  enableVoice: %d\n", g_schedule_reminder.enableVoice);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  enableVibration: %d\n", g_schedule_reminder.enableVibration);
 
     #if 0
     // 推送文本和日程提醒内容数据给ui
@@ -292,7 +292,7 @@ void ln_parse_schedule_reminder_config(const char *json_buf, int json_len)
 {
     if (!json_buf || json_len <= 0)
     {
-        printf("[SCHEDULE_REMINDER_CONFIG] invalid json input\n");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER_CONFIG] invalid json input\n");
         return;
     }
 
@@ -307,7 +307,7 @@ void ln_parse_schedule_reminder_config(const char *json_buf, int json_len)
     cJSON *root = cJSON_Parse(text);
     if (!root)
     {
-        printf("[SCHEDULE_REMINDER_CONFIG] json parse failed\n");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER_CONFIG] json parse failed\n");
         free(text);
         return;
     }
@@ -316,7 +316,7 @@ void ln_parse_schedule_reminder_config(const char *json_buf, int json_len)
     cJSON *errorCode = cJSON_GetObjectItem(root, "errorCode");
     if (errorCode && !cJSON_IsNull(errorCode))
     {
-        printf("[SCHEDULE_REMINDER_CONFIG] server error: %s\n",
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER_CONFIG] server error: %s\n",
                cJSON_IsString(errorCode) ? errorCode->valuestring : "unknown");
         cJSON_Delete(root);
         free(text);
@@ -327,7 +327,7 @@ void ln_parse_schedule_reminder_config(const char *json_buf, int json_len)
     cJSON *data = cJSON_GetObjectItem(root, "data");
     if (!data || !cJSON_IsObject(data))
     {
-        printf("[SCHEDULE_REMINDER_CONFIG] no data object\n");
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER_CONFIG] no data object\n");
         cJSON_Delete(root);
         free(text);
         return;
@@ -350,10 +350,10 @@ void ln_parse_schedule_reminder_config(const char *json_buf, int json_len)
                   (displayText && cJSON_IsString(displayText)) ? displayText->valuestring : "");
 
     // 打印解析结果
-    printf("[SCHEDULE_REMINDER_CONFIG] parsed successfully:\n");
-    printf("  scheduleName: %s\n", g_schedule_reminder_config.scheduleName ? g_schedule_reminder_config.scheduleName : "");
-    printf("  scheduleId: %d\n", g_schedule_reminder_config.scheduleId);
-    printf("  displayText: %s\n", g_schedule_reminder_config.displayText ? g_schedule_reminder_config.displayText : "");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER_CONFIG] parsed successfully:\n");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  scheduleName: %s\n", g_schedule_reminder_config.scheduleName ? g_schedule_reminder_config.scheduleName : "");
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  scheduleId: %d\n", g_schedule_reminder_config.scheduleId);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "  displayText: %s\n", g_schedule_reminder_config.displayText ? g_schedule_reminder_config.displayText : "");
 
     // 推送任务提醒通知
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[SCHEDULE_REMINDER_CONFIG] push task reminder notification\n");
index d8af03a..a24e65c 100644 (file)
@@ -142,6 +142,9 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
     if (!header_buf)
     {
         free(body);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     int hdr = snprintf(header_buf, 512,
@@ -154,6 +157,9 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
     {
         free(body);
         free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -164,6 +170,10 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
     if (prep != HTTP_SUCCESS)
     {
         free(body);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
 
@@ -181,6 +191,10 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
         printf("connection failed, ret=0x%x\n", ret);
         free(body);
         HttpClientUnprepare(&clientData);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ret;
     }
 
@@ -191,6 +205,10 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
         free(body);
         HttpClientClse(&client);
         HttpClientUnprepare(&clientData);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ret;
     }
 
@@ -201,6 +219,10 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
         free(body);
         HttpClientClse(&client);
         HttpClientUnprepare(&clientData);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
 
@@ -224,6 +246,10 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
                     HttpClientClse(&client);
                     HttpClientUnprepare(&clientData);
                     fclose(fd);
+                    free(header_buf);
+                    #ifdef SUPPORT_CAT1_SERVICE
+                    cat1_api_remove_cat1_vote();
+                    #endif
                     return ERRCODE_FAIL;
                 }
                 total_written += written;
@@ -245,7 +271,11 @@ uint32_t ln_speech_chat_stream_http(const char *device_id,
     HttpClientClse(&client);
     free(body);
     fclose(fd);
+    free(header_buf);
+    #ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+    #endif
 
 
     return ERRCODE_SUCC;
-}
+}
\ No newline at end of file
index ff47e5e..5b23f83 100644 (file)
@@ -139,6 +139,9 @@ uint32_t ln_story_choose_http(const char *device_id,
     if (!header_buf)
     {
         free(body);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     int hdr = snprintf(header_buf, 1024,
@@ -152,6 +155,9 @@ uint32_t ln_story_choose_http(const char *device_id,
         printf("story choose: build header failed\n");
         free(body);
         free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -163,6 +169,10 @@ uint32_t ln_story_choose_http(const char *device_id,
     {
         printf("story choose: prepare HTTP buffer failed (code: %d)\n", prep);
         free(body);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
 
@@ -179,6 +189,10 @@ uint32_t ln_story_choose_http(const char *device_id,
         printf("connection failed, ret=0x%x\n", ret);
         free(body);
         HttpClientUnprepare(&clientData);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ret;
     }
 
@@ -189,6 +203,10 @@ uint32_t ln_story_choose_http(const char *device_id,
         free(body);
         HttpClientClse(&client);
         HttpClientUnprepare(&clientData);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ret;
     }
 
@@ -199,6 +217,10 @@ uint32_t ln_story_choose_http(const char *device_id,
         free(body);
         HttpClientClse(&client);
         HttpClientUnprepare(&clientData);
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
 
@@ -221,6 +243,10 @@ uint32_t ln_story_choose_http(const char *device_id,
                     HttpClientClse(&client);
                     HttpClientUnprepare(&clientData);
                     fclose(fd);
+                    free(header_buf);
+                    #ifdef SUPPORT_CAT1_SERVICE
+                    cat1_api_remove_cat1_vote();
+                    #endif
                     return ERRCODE_FAIL;
                 }
                 total_written += written;
@@ -242,6 +268,10 @@ uint32_t ln_story_choose_http(const char *device_id,
     HttpClientUnprepare(&clientData);
     HttpClientClse(&client);
     fclose(fd);
+    free(header_buf);
+    #ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+    #endif
 
     return ERRCODE_SUCC;
 }
index 483e203..686187b 100644 (file)
@@ -21,7 +21,12 @@ uint32_t ln_story_exit_inquiry_http(const char *device_id,
     /* 普通JSON头 */
     char *header_buf = (char *)malloc(512);
     if (!header_buf)
+    {
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
+    }
     int hdr = snprintf(header_buf, 512,
                        "deviceId: %s\r\ndeviceToken: %s\r\nContent-Type: application/json\r\n",
                        device_id, device_token);
@@ -29,13 +34,21 @@ uint32_t ln_story_exit_inquiry_http(const char *device_id,
     if (hdr <= 0)
     {
         free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
 
     HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, 8 * 1024);
     if (prep != HTTP_SUCCESS)
+    {
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
+    }
 
     clientData.postBuf = (char *)"{}";
     clientData.postBufLen = 2;
@@ -67,5 +80,8 @@ end:
     HttpClientClse(&client);
     if (header_buf)
         free(header_buf);
+    #ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+    #endif
     return ERRCODE_SUCC;
 }
index 7c9a79c..41fdced 100644 (file)
@@ -21,19 +21,34 @@ uint32_t ln_story_finish_http(const char *device_id,
 
     char *header_buf = (char *)malloc(512);
     if (!header_buf)
+    {
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
+    }
     int hdr = snprintf(header_buf, 512,
                        "deviceId: %s\r\ndeviceToken: %s\r\nContent-Type: application/json\r\n",
                        device_id, device_token);
     if (hdr <= 0)
     {
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
 
     HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, 8 * 1024);
     if (prep != HTTP_SUCCESS)
+    {
+        free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
+    }
 
     clientData.postBuf = (char *)"{}";
     clientData.postBufLen = 2;
@@ -65,5 +80,8 @@ end:
     HttpClientUnprepare(&clientData);
     HttpClientClse(&client);
     free(header_buf);
+    #ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+    #endif
     return ERRCODE_SUCC;
 }
index 8e677db..2d405d6 100644 (file)
@@ -44,6 +44,9 @@ uint32_t ln_story_random_http(const char *device_id,
     if (hdr <= 0)
     {
         free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     HttpClientSetCustomHeader(&client, header_buf);
@@ -54,6 +57,9 @@ uint32_t ln_story_random_http(const char *device_id,
     {
         printf("story random: prepare HTTP buffer failed (code: %d)\n", prep);
         free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
 
@@ -67,6 +73,9 @@ uint32_t ln_story_random_http(const char *device_id,
         if (escaped_theme)
             free(escaped_theme);
         free(header_buf);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
     int json_len = 0;
@@ -93,6 +102,9 @@ uint32_t ln_story_random_http(const char *device_id,
         free(header_buf);
         free(json_body);
         free(escaped_theme);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
 
@@ -110,6 +122,9 @@ uint32_t ln_story_random_http(const char *device_id,
         free(json_body);
         free(escaped_theme);
         HttpClientUnprepare(&clientData);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ret;
     }
 
@@ -123,6 +138,10 @@ uint32_t ln_story_random_http(const char *device_id,
         free(header_buf);
         free(json_body);
         free(escaped_theme);
+        HttpClientUnprepare(&clientData);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ret;
     }
 
@@ -135,6 +154,10 @@ uint32_t ln_story_random_http(const char *device_id,
         free(header_buf);
         free(json_body);
         free(escaped_theme);
+        HttpClientUnprepare(&clientData);
+        #ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+        #endif
         return ERRCODE_FAIL;
     }
 
@@ -159,6 +182,10 @@ uint32_t ln_story_random_http(const char *device_id,
                     free(header_buf);
                     free(json_body);
                     free(escaped_theme);
+                    HttpClientUnprepare(&clientData);
+                    #ifdef SUPPORT_CAT1_SERVICE
+                    cat1_api_remove_cat1_vote();
+                    #endif
                     return ERRCODE_FAIL;
                 }
                 total_written += written;
@@ -182,6 +209,9 @@ uint32_t ln_story_random_http(const char *device_id,
     free(header_buf);
     free(json_body);
     free(escaped_theme);
+    #ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+    #endif
     return ERRCODE_SUCC;
 }
 
index 3fbe12b..4b6fa65 100644 (file)
@@ -76,6 +76,9 @@ uint32_t ln_timeline_get_status_http(const char *device_id,
        char *header_buf = (char *)malloc(512);
        if (!header_buf)
        {
+#ifdef SUPPORT_CAT1_SERVICE
+               cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
                return ERRCODE_FAIL;
        }
@@ -87,6 +90,9 @@ uint32_t ln_timeline_get_status_http(const char *device_id,
        if (hdr <= 0)
        {
                free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+               cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
                return ERRCODE_FAIL;
        }
@@ -96,6 +102,9 @@ uint32_t ln_timeline_get_status_http(const char *device_id,
        if (prep != HTTP_SUCCESS)
        {
                free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+               cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
                return ERRCODE_FAIL;
        }
@@ -120,6 +129,9 @@ end:
        HttpClientUnprepare(&clientData);
        HttpClientClse(&client);
        free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+       cat1_api_remove_cat1_vote();
+#endif
        uapi_ln_remove_vote();
        return ERRCODE_SUCC;
 }
index 14f0e1f..af2cd81 100644 (file)
@@ -302,6 +302,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_get_device_token_http: HttpClientPrepare failed %d", prep);
         free(sign_data);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
         return ERRCODE_FAIL;
     }
@@ -314,6 +317,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
         HttpClientClse(&client);
         free(sign_data);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
         return ERRCODE_FAIL;
     }
@@ -326,6 +332,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
         HttpClientClse(&client);
         free(sign_data);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
         return ERRCODE_FAIL;
     }
@@ -338,6 +347,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
         HttpClientClse(&client);
         free(sign_data);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
         return ERRCODE_FAIL;
     }
@@ -353,6 +365,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
         HttpClientClse(&client);
         free(sign_data);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
         return ERRCODE_FAIL;
     }
@@ -368,6 +383,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
         HttpClientClse(&client);
         free(sign_data);
         free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
         return ERRCODE_FAIL;
     }
@@ -383,6 +401,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
         free(json_text);
         HttpClientUnprepare(&clientData);
         HttpClientClse(&client);
+#ifdef SUPPORT_CAT1_SERVICE
+        cat1_api_remove_cat1_vote();
+#endif
                uapi_ln_remove_vote();
         return ERRCODE_FAIL;
     }
@@ -429,6 +450,9 @@ uint32_t ln_get_device_token_http(const char *device_id,
     HttpClientClse(&client);
     free(sign_data);
     free(header_buf);
+#ifdef SUPPORT_CAT1_SERVICE
+    cat1_api_remove_cat1_vote();
+#endif
        uapi_ln_remove_vote();
     return ERRCODE_SUCC;
 }