解决安卓连接耳机问题 1030/1 1030/head 1031/target/1
authorhcj <1224667075@qq.com>
Fri, 27 Sep 2024 06:38:25 +0000 (14:38 +0800)
committerhcj <1224667075@qq.com>
Fri, 27 Sep 2024 06:38:25 +0000 (14:38 +0800)
code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothCaseListAdapter.cpp

index a9003d3..43b5246 100644 (file)
@@ -89,15 +89,28 @@ public:
 
         // 判断是否正在连接
         bd_addr_t *lastAddr = BluetoothModel::GetInstance()->GetLastConnedAddr();
+
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal = %02X %02X %02X * * *",
+           lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]);
+        
+     
         bool ret = bt_is_acl_connected(lastAddr);
-        if (ret) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal =  ret %d %02X %02X %02X * * *",
+           ret, lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]);
+        
+        
+        if (!( lastAddr->addr[0] == 0 && lastAddr->addr[1] == 0 && lastAddr->addr[2] == 0
+         && lastAddr->addr[3] == 0 && lastAddr->addr[4] == 0 && lastAddr->addr[5] == 0 ) && ret) {
             BluetoothModel::GetInstance()->SetTagConnectNew(true);
             errcode_t retVal = gap_disconnect_remote_device(lastAddr);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal =  %d", retVal);
-        } else {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disconnect LastDevice retVal =  %d %02X %02X %02X * * *", retVal,
+            lastAddr->addr[0],lastAddr->addr[1],lastAddr->addr[2]);
+        }
+        else
+        {
             mainBluetoothView->ChangeView(BluetoothModel::GetInstance()->GetCurView(), BLUETOOTHRECONNECTVIEW);
             errcode_t retVal = BluetoothModel::GetInstance()->ConnectRemoteDevice(&addr);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret =  %d", retVal);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ConnectRemoteDevice ret =  %d", retVal);
         }
         // 跳转可选页
         return true;