From 5f60f02bf6af1df17e1f80751fa73a424afe98d0 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 1 Dec 2025 10:54:44 +0800 Subject: [PATCH] =?utf8?q?=E9=9B=B7=E9=B8=9F=EF=BC=9A=E8=93=9D=E7=89=99?= =?utf8?q?=E8=80=B3=E6=9C=BA=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96=EF=BC=8C?= =?utf8?q?=E4=B8=8A=E6=8A=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/bluetooth/src/BluetoothModel.cpp | 20 +++++++++---------- .../bluetooth/src/Ln_Bluetooth_apiC.cpp | 4 ++-- .../src/ThunderBirdBlueListAdapter.cpp | 2 +- .../thunderbird/src/ThunderBirdModel.cpp | 4 ++++ .../thunderbird/src/ThunderBirdPresenter.cpp | 7 ++++++- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp index 0e2f571b1..f09f6954a 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/BluetoothModel.cpp @@ -126,7 +126,7 @@ void BluetoothModel::Init() // 设置自动回连,ios一键双连依赖此配置 bts_feature_t bts_feature = { 0 }; - bts_feature.bt_auto_reconnect_closed = 0; + bts_feature.bt_auto_reconnect_closed = 1; ret = bts_set_features(&bts_feature); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "bt bts_set_features ret = %u", ret); @@ -146,7 +146,7 @@ void BluetoothModel::Init() BtInitGatts(); BtInitSpp(); InitBtHeadsetEvent(); // 蓝牙ct和tg适配初始化 - // PhoneServiceInit(); + PhoneServiceInit(); // gap_remove_all_pairs(); BtA2dpInit(); @@ -1052,7 +1052,7 @@ void ChangeBleConnectToDefault() // 回调:ACL连接状态上报 void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, unsigned int reason) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bt GapAclStateChangedCallback state %d, reason %x succ or err", state, reason); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ACL连接状态上报 state %d, reason %x succ or err", state, reason); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "addr: %02x%02x%02x%02x%02x%02x", bdAddr->addr[5], bdAddr->addr[4], bdAddr->addr[3], /* mac下标 0 1 2 3 4 5 */ bdAddr->addr[2], bdAddr->addr[1], bdAddr->addr[0]); /* mac下标 0 1 2 3 4 5 */ @@ -1061,21 +1061,21 @@ void GapAclStateChangedCallback(const bd_addr_t *bdAddr, gap_acl_state_t state, WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GapAclStateChangedCallback: Mobile Phone Device"); if (state == GAP_ACL_STATE_DISCONNECTED) { /* 通知msg_center,ble状态仍用bt状态,此处不区分 */ - MsgCenterSendMsg(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); - SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); + // MsgCenterSendMsg(BT_DISCONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToUIService(BT_DISCONNECTED_TO_UI, 0, nullptr, 0); // send to ace network // SetAclConnected(false); - net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_DISCONNECTED); + // net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_DISCONNECTED); } else if (state == GAP_ACL_STATE_CONNECTED) { (void)memcpy_s(gapAclConnectAddr.addr, BD_ADDR_LEN, bdAddr->addr, BD_ADDR_LEN); - MsgCenterSendMsg(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); - SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); + // MsgCenterSendMsg(BT_CONNECTED_TO_MSGCENTER, 0, nullptr, 0); + // SendMsgToUIService(BT_CONNECTED_TO_UI, 0, nullptr, 0); // send to ace network // SetAclConnected(true); #if defined(SUPPORT_LWIP) && defined(SUPPORT_BREDR) - bt_pan_open(); + // bt_pan_open(); #endif - net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_CONNECTED); + // net_connect_status_change(NETWORK_TYPE_BLUETOOTH, CONNECTION_STATUS_CONNECTED); } return; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp index d82bce560..02e2c6b0b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/bluetooth/src/Ln_Bluetooth_apiC.cpp @@ -262,7 +262,7 @@ extern "C" // 只有在已连接状态下才能发送状态报告 if (ln_ws_get_connection_state() != 2) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: ws not connected"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: ws not connected"); return 0; } @@ -283,7 +283,7 @@ extern "C" (lastAddr->addr[2] == 0) && (lastAddr->addr[3] == 0) && (lastAddr->addr[4] == 0) && (lastAddr->addr[5] == 0)) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: lastAddr is empty"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ln_bt_report_earphone_connection_status: lastAddr is empty"); char *bluetoothStatus = "DISCONNECTED"; do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_BLUETOOTH_STATUS_REPORT, bluetoothStatus, strlen(bluetoothStatus)); return 0; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdBlueListAdapter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdBlueListAdapter.cpp index 4c7db5dd4..034971474 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdBlueListAdapter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdBlueListAdapter.cpp @@ -24,7 +24,7 @@ constexpr int64_t COLOR_ITEM_BG = 0xFFAD590B; // 设备项背景色( constexpr int64_t COLOR_BORDER_SELECTED = 0xFFED6C00; // 选中边框颜色(橙色) constexpr int64_t COLOR_TEXT_WHITE = 0xFFFFFFFF; // 白色文字 constexpr int64_t COLOR_TEXT_GRAY = 0xFFCCCCCC; // 灰色文字(分组标题) -constexpr int64_t COLOR_CONNECTED_DOT = 0xFFED6C00; // 已连接指示点颜色(橙色) +constexpr int64_t COLOR_CONNECTED_DOT = 0xFF4FC34C; // 已连接指示点颜色(绿色) //======================================== // ThunderBirdBlueDeviceItemView 实现 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 473f1eee0..d8b52f8c5 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 @@ -475,6 +475,10 @@ extern "C" { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "恢复出厂:删除雷鸟文件夹 /user/leiniao"); return false; } + if(gap_remove_all_pairs() == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "恢复出厂: 删除所有配对失败"); + } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "恢复出厂: 成功"); //重启 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index 796c142a5..143e50ae4 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -42,6 +42,7 @@ #ifdef CUSTOM_UTILS #include "custom_utils.h" #endif +#include "bluetooth/Ln_Bluetooth_apiC.h" namespace OHOS { // 静态回调函数声明 @@ -843,7 +844,6 @@ namespace OHOS ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_BLUEVIEW, ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_SREACHING); break; case ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DISCONNECT_SUCCESS: - //蓝牙已断开,返回搜索界面,提示用户重新搜索 ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW); break; case ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DEVICE_LIST: @@ -872,6 +872,10 @@ namespace OHOS //返回设备列表 ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_BLUEVIEW, ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DEVICE_LIST); break; + case ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DISCONNECT_SUCCESS: + //蓝牙已断开,返回搜索界面,提示用户重新搜索 + ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_BLUEVIEW, ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DEVICE_LIST); + break; case ThunderBirdBlueView::THUNDERBIRD_BULEVIEW_DEVICE_LIST: ThunderBirdBlueView::GetInstance()->OnKeyDown();// 音量-键:选择下一个设备 break; @@ -1093,6 +1097,7 @@ namespace OHOS ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW); break; } + ln_bt_report_earphone_connection_status(); } } } -- 2.17.1