From e1b00da06ed76e0900168aa5b3ea398a7328609c Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 26 Nov 2025 10:14:23 +0800 Subject: [PATCH] =?utf8?q?ln=EF=BC=9A=E6=B7=BB=E5=8A=A0=E9=80=9A=E7=9F=A5?= =?utf8?q?=E8=BF=9B=E8=A1=8C=E8=93=9D=E7=89=99=E8=80=B3=E6=9C=BA=E8=BF=9E?= =?utf8?q?=E6=8E=A5=E6=93=8D=E4=BD=9C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/include/uiservice/ui_service.h | 1 + .../thunderbird/include/ThunderBirdModel.h | 3 +++ .../nativeui/thunderbird/src/ThunderBirdModel.cpp | 6 ++++++ .../nativeui/uiservice/src/ui_service.cpp | 14 ++++++++++++++ code/sdk/zhihui/leiniao/imsl_ln/ln_api.c | 4 ---- code/sdk/zhihui/leiniao/imsl_ln/ln_bluetooth_api.c | 5 +++++ .../zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp | 6 ++++++ .../zhihui/leiniao/ln_api_cpp/ln_api_interface.h | 2 ++ 8 files changed, 37 insertions(+), 4 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 d7e8d9f75..954055ac0 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 @@ -75,6 +75,7 @@ typedef enum { HAND_UPGRADE_DESCRIPTION_NOTIFY, // 升级描述通知 HAND_STORY_RESPONSE_FINISHED_NOTIFY, // 故事响应finished通知 HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY, // 对话响应finished通知 + HAND_BLUETOOTH_CONNECT_NOTIFY, // 蓝牙耳机连接通知 MAX_NUM_HANDLER, } UiServiceMsgId; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index 96b6c104e..36431b5ac 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -224,6 +224,9 @@ namespace OHOS // 处理故事响应消息的finished标志 void HandleStoryResponseFinished(bool finished); + // 处理蓝牙耳机连接通知 + void HandleBluetoothConnect(const char *bluetoothAddress); + // 处理对话响应消息的finished标志 void HandleDialogueResponseFinished(bool finished); // 减低视频帧率 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index e37650031..8c30a70b1 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -2490,6 +2490,12 @@ extern "C" { } } + void ThunderBirdModel::HandleBluetoothConnect(const char *bluetoothAddress) + { + // bluetoothAddress//保留字段,暂时无用 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleBluetoothConnect: 收到蓝牙耳机连接通知,bluetoothAddress=%s", bluetoothAddress); + } + void ThunderBirdModel::HandleBindAndUnbind(int is_bind) { if(is_bind == 1) 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 a23ea2839..968cbb383 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 @@ -111,6 +111,8 @@ static void HandTimelineStatusChangeNotify(Request *request); static void HandUpgradeDescriptionNotify(Request *request); static void HandStoryResponseFinishedNotify(Request *request); static void HandDialogueResponseFinishedNotify(Request *request); +static void HandBluetoothConnectNotify(Request *request); + // 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头) MsgHandlerEntry msgHandlers[] = { {HANDLE_JUMP_OTA_VIEW, HandleJumpOtaView}, @@ -138,6 +140,7 @@ MsgHandlerEntry msgHandlers[] = { {HAND_UPGRADE_DESCRIPTION_NOTIFY,HandUpgradeDescriptionNotify}, {HAND_STORY_RESPONSE_FINISHED_NOTIFY,HandStoryResponseFinishedNotify}, {HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY,HandDialogueResponseFinishedNotify}, + {HAND_BLUETOOTH_CONNECT_NOTIFY,HandBluetoothConnectNotify}, }; /* -------------------------------------------------------------------------- */ void ScreenTurnOn(int32_t timeout) @@ -816,6 +819,17 @@ void HandDialogueResponseFinishedNotify(Request *request) OHOS::ThunderBirdModel::GetInstance(), finished)); } } +// 通知蓝牙耳机连接操作 +void HandBluetoothConnectNotify(Request *request) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandBluetoothConnectNotify msg_id = %d", request->msgId); + // std::string bluetoothAddress(static_cast(request->data), request->len); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandBluetoothConnectNotify bluetoothAddress = %s", bluetoothAddress.c_str()); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&OHOS::ThunderBirdModel::HandleBluetoothConnect, + OHOS::ThunderBirdModel::GetInstance(), "AA:BB:CC:DD:EE:FF"));//要连接的蓝牙设备MAC地址,保留字段,暂时无用 + +} /* -------------------------------------------------------------------------- */ #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 0bd797fce..0539e34c2 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -927,10 +927,6 @@ void ln_ws_process_message(const ws_data_msg_t *data_msg, ws_command_t type) if (json_str) { ln_parse_bluetooth_connect(json_str, (int)strlen(json_str)); - /* 发送蓝牙连接应答 */ - ln_ws_send_bluetooth_connect_ack(true, "蓝牙连接中"); - /* TODO: 这里应该调用实际的蓝牙连接接口,执行搜索和连接操作 */ - /* 连接完成后,通过BluetoothStatusReport命令上报最终状态 */ } break; } diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_bluetooth_api.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_bluetooth_api.c index e48b1a8fc..f90ea0cd3 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_bluetooth_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_bluetooth_api.c @@ -233,6 +233,11 @@ void ln_parse_bluetooth_connect(const char *json_str, int json_len) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[BT] BluetoothConnect - userId: %s, bluetoothAddress: %s", g_bluetooth_connect_data.user_id, g_bluetooth_connect_data.bluetooth_address); + // 发送蓝牙连接通知 + push_bluetooth_connect_notification(g_bluetooth_connect_data.bluetooth_address); + /* 发送蓝牙连接应答 */ + ln_ws_send_bluetooth_connect_ack(true, "蓝牙连接中"); + cJSON_Delete(root); free(text); } 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 22ec66451..f084027fc 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 @@ -323,6 +323,12 @@ void push_dialogue_response_finished_notification(bool finished) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[DIALOGUE_RESPONSE_FINISHED] finished=%d", finished); SendMsgToUIService(HAND_DIALOGUE_RESPONSE_FINISHED_NOTIFY, 0, &finished, sizeof(finished)); } +//通知进行蓝牙耳机连接操作 +void push_bluetooth_connect_notification(const char *bluetoothAddress) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[BLUETOOTH_CONNECT] bluetoothAddress=%s", bluetoothAddress); + SendMsgToUIService(HAND_BLUETOOTH_CONNECT_NOTIFY, 0, (void *)bluetoothAddress, (int32_t)strlen(bluetoothAddress)); +} #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 1ca3442d6..0d9330275 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 @@ -117,6 +117,8 @@ void push_upgrade_description_notification(const char *description); void push_story_response_finished_notification(bool finished); //通知对话响应finished void push_dialogue_response_finished_notification(bool finished); +//通知进行蓝牙耳机连接操作 +void push_bluetooth_connect_notification(const char *bluetoothAddress); #ifdef __cplusplus } #endif -- 2.17.1