添加对话过程中npc表情变化通知 2502/1
authorluozheng <1732036298@qq.com>
Tue, 14 Oct 2025 07:01:39 +0000 (15:01 +0800)
committerluozheng <1732036298@qq.com>
Tue, 14 Oct 2025 07:01:39 +0000 (15:01 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h
code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp
code/sdk/zhihui/leiniao/imsl_ln/ln_api.c
code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_random.c
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp
code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h

index bd64f64..c6c8540 100644 (file)
@@ -66,6 +66,7 @@ typedef enum {
     HAND_DOWNLOAD_FAIL_NOTIFY, // 下载失败通知
     HAND_DOWNLOAD_PROGRESS_NOTIFY, // 下载进度通知
     HAND_AUDIO_PLAYBACK_END_NOTIFY, // 音频播放结束通知
+    HAND_NPC_EMOTION_CHANGE_NOTIFY, // npc表情变化通知
     MAX_NUM_HANDLER, 
 } UiServiceMsgId;
 
index 05054b2..4051721 100644 (file)
@@ -102,6 +102,7 @@ static void HandDownloadSuccessNotify(Request *request);
 static void HandDownloadFailNotify(Request *request);
 static void HandDownloadProgressNotify(Request *request);
 static void HandAudioPlaybackEndNotify(Request *request);
+static void HandNpcEmotionChangeNotify(Request *request);
 // 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头)
 MsgHandlerEntry msgHandlers[] = {
     {HANDLE_JUMP_OTA_VIEW, HandleJumpOtaView},
@@ -120,6 +121,7 @@ MsgHandlerEntry msgHandlers[] = {
     {HAND_DOWNLOAD_FAIL_NOTIFY,HandDownloadFailNotify},
     {HAND_DOWNLOAD_PROGRESS_NOTIFY,HandDownloadProgressNotify},
     {HAND_AUDIO_PLAYBACK_END_NOTIFY,HandAudioPlaybackEndNotify},
+    {HAND_NPC_EMOTION_CHANGE_NOTIFY,HandNpcEmotionChangeNotify},
 };
 /* -------------------------------------------------------------------------- */
 void ScreenTurnOn(int32_t timeout)
@@ -614,6 +616,13 @@ void HandAudioPlaybackEndNotify(Request *request)
     GraphicService::GetInstance()->PostGraphicEvent(
         std::bind(&OHOS::ThunderBirdModel::HandleAudioPlaybackEnd,OHOS::ThunderBirdModel::GetInstance()));
 }
+// 通知npc表情变化
+void HandNpcEmotionChangeNotify(Request *request)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandNpcEmotionChangeNotify msg_id = %d", request->msgId);
+    std::string emotion(static_cast<char*>(request->data), request->len);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandNpcEmotionChangeNotify emotion = %s", emotion.c_str());
+}
 /* -------------------------------------------------------------------------- */
 #ifdef __cplusplus
 }
index 4de93ce..de709aa 100644 (file)
@@ -560,11 +560,11 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type)
         set_is_ln_get_device_network_success(0);
     }
 
-    if (!data_msg || !data_msg->raw_json)
-    {
-        printf("[WS] invalid data message\n");
-        return;
-    }
+    // if (!data_msg || !data_msg->raw_json)
+    // {
+    //     printf("[WS] invalid data message\n");
+    //     return;
+    // }
 
     const char *json_str = data_msg->raw_json;
     const char *message_id = data_msg->message_id;
@@ -628,7 +628,7 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type)
         printf("[WS] ScheduleReminder:日程提醒\n");
         if (json_str)
         {
-            do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_SCHEDULE_REMINDER, NULL, 0);
+            do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_SCHEDULE_REMINDER, json_str, strlen(json_str));
         }
         break;
     }
index a6e289e..218e4e7 100644 (file)
@@ -285,6 +285,7 @@ void ln_parse_voice_chat_response(const char *json_str, int json_len)
     if (npc_emotion_str)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NPC情感状态: %s\n", npc_emotion_str);
+        push_npc_emotion_change_notification(npc_emotion_str);
     }
     else
     {
index 36159ed..1adf043 100644 (file)
@@ -259,6 +259,12 @@ void push_audio_playback_end_notification(void)
 {
     SendMsgToUIService(HAND_AUDIO_PLAYBACK_END_NOTIFY, 0, NULL, 0);
 }
+//通知npc表情变化
+void push_npc_emotion_change_notification(const char *emotion)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[NPC_EMOTION_CHANGE] emotion=%s", emotion);
+    SendMsgToUIService(HAND_NPC_EMOTION_CHANGE_NOTIFY, 0, (void *)emotion, (int32_t)strlen(emotion));
+}
 #ifdef __cplusplus
 };
 #endif
\ No newline at end of file
index 8fa6d05..7675e2d 100644 (file)
@@ -100,6 +100,8 @@ void push_download_fail_notification(int type);
 void push_download_progress_notification(int progress);
 //通知音频播放结束了
 void push_audio_playback_end_notification(void);
+//通知npc表情变化
+void push_npc_emotion_change_notification(const char *emotion);
 #ifdef __cplusplus
 }
 #endif