From 0caa7f112fba9d1c098c56b686fee4a4036c80b2 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 14 Oct 2025 15:01:39 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=E8=AF=9D=E8=BF=87?= =?utf8?q?=E7=A8=8B=E4=B8=ADnpc=E8=A1=A8=E6=83=85=E5=8F=98=E5=8C=96?= =?utf8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/include/uiservice/ui_service.h | 1 + .../nativeapp/nativeui/uiservice/src/ui_service.cpp | 9 +++++++++ code/sdk/zhihui/leiniao/imsl_ln/ln_api.c | 12 ++++++------ .../sdk/zhihui/leiniao/imsl_ln/ln_api_story_random.c | 1 + .../zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp | 6 ++++++ .../sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h | 2 ++ 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h index bd64f6448..c6c8540b8 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/include/uiservice/ui_service.h @@ -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; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp index 05054b273..4051721e2 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp @@ -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(request->data), request->len); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandNpcEmotionChangeNotify emotion = %s", emotion.c_str()); +} /* -------------------------------------------------------------------------- */ #ifdef __cplusplus } diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c index 4de93ce6a..de709aab7 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -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; } diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_random.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_random.c index a6e289e43..218e4e707 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_random.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api_story_random.c @@ -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 { diff --git a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp index 36159ed1e..1adf04350 100644 --- a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp +++ b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp @@ -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 diff --git a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h index 8fa6d05e9..7675e2d54 100644 --- a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h +++ b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.h @@ -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 -- 2.17.1