Reputation: 2106
I am working on Bluetooth Low Energy Device(Weight Scale).
I have observed few things. When I am trying to disconnect with BLE device, it disconnects. I also removing bond by calling following line.
method = mBluetoothGatt.getDevice().getClass().getMethod("removeBond", (Class[]) null);
method.invoke(mBluetoothGatt.getDevice(), (Object[]) null);
But after few seconds suddenly it shows as it is connected with my Mobile device. When I turned OFF Bluetooth of my mobile device, it(scale) still shows connected symbol. It will only disconnects when I change my mobile device to Airplane mode.
I saw following logs in Android Monitor.
11-14 10:55:23.438 15152-15207/? W/bt_btif: bta_dm_bl_change_cback : reason=0
11-14 10:55:23.438 15152-15207/? W/bt_btm: btm_acl_update_busy_level :: evt.busy_level_flags : 0x0
11-14 10:55:23.438 15152-15207/? W/bt_btif: bta_dm_bl_change_cback : reason=0
11-14 10:55:23.439 15152-15207/? W/bt_smp: smp_br_connect_callback is called on unexpected transport 2
11-14 10:55:23.439 15152-15207/? W/bt_btif: bta_dm_acl_change info: 0x0
11-14 10:55:23.439 15152-15178/? W/bt_btif: btif_dm_upstreams_cback ev: BTA_DM_LINK_UP_EVT
11-14 10:55:23.439 15152-15178/? W/bt_btif: BTA_DM_LINK_UP_EVT. Sending BT_ACL_STATE_CONNECTED
11-14 10:55:23.443 18042-18042/com.beurer.connect.healthmanager 11-14 10:55:23.449 15152-15178/? D/BluetoothUtils: getBtEnabledContainers(): btContainers = []
11-14 10:55:23.472 15152-15178/? E/BluetoothRemoteDevices: aclStateChangeCallback: State:Connected to Device:18:7A:93:4C:69:XX, linktype is 2
11-14 10:55:23.479 15152-15178/? D/BluetoothUtils: getBtEnabledContainers(): btContainers = []
11-14 10:55:23.481 15152-15178/? W/bt_btif: btif_dm_upstreams_cback ev: BTA_DM_BUSY_LEVEL_EVT
11-14 10:55:23.482 15152-15178/? W/bt_btif: BTA_DM_BUSY_LEVEL_EVT :: p_data->busy_level.level_flags : 0x0
11-14 10:55:23.484 18107-18107/? D/oneconnect[1.6.05-45_2]: BluetoothHelper.mBtStateReceiver - [action]android.bluetooth.device.action.ACL_CONNECTED [connState]0[address] - ($)
11-14 10:55:23.488 3763-3848/? D/CompatibilityInfo: mCompatibilityFlags - 0
11-14 10:55:23.488 3763-3848/? D/CompatibilityInfo: applicationDensity - 480
11-14 10:55:23.488 3763-3848/? D/CompatibilityInfo: applicationScale - 1.0
11-14 10:55:23.493 18107-18133/? D/BluetoothA2dp: getState(18:7A:93:4C:69:XX)
11-14 10:55:23.493 3763-3763/? D/KnoxKeyguardUpdateMonitor: BroadcastReceiver onReceive
11-14 10:55:23.493 3763-3763/? D/KnoxKeyguardUpdateMonitor: BroadcastReceiver onReceive action: android.bluetooth.device.action.ACL_CONNECTED
11-14 10:55:23.493 3763-3763/? D/KnoxKeyguardUpdateMonitor: BroadcastReceiver ACTION_ACL_CONNECTED
11-14 10:55:23.503 3763-4488/? D/CompatibilityInfo: mCompatibilityFlags - 0
11-14 10:55:23.503 3763-4488/? D/CompatibilityInfo: applicationDensity - 480
11-14 10:55:23.503 3763-4488/? D/CompatibilityInfo: applicationScale - 1.0
11-14 10:55:23.513 15152-15342/? D/A2dpStateMachine: getConnectionState: 0
11-14 10:55:23.514 3763-4436/? D/CompatibilityInfo: mCompatibilityFlags - 0
11-14 10:55:23.514 3763-4436/? D/CompatibilityInfo: applicationDensity - 480
11-14 10:55:23.515 3763-4436/? D/CompatibilityInfo: applicationScale - 1.0
11-14 10:55:23.519 18107-18133/? D/BluetoothHeadset: getConnectionState() in if statement
11-14 10:55:23.519 15152-15956/? W/HeadsetService: getConnectionState
11-14 10:55:23.523 15152-15956/? W/HeadsetService: get Service
11-14 10:55:23.523 15152-15956/? W/HeadsetService: service is not null
11-14 10:55:23.524 4983-4983/? W/SearchService: Abort, client detached.
11-14 10:55:23.524 15152-15956/? D/HeadsetService: enter getConnectionState
11-14 10:55:23.525 15152-15956/? D/HeadsetService: getConnectionState is 0
11-14 10:55:23.525 15152-15956/? W/HeadsetService: ret = 0
11-14 10:55:23.527 4983-4983/? I/BistoWorker: handleCommonBroadcastIntent: android.bluetooth.device.action.ACL_CONNECTED
11-14 10:55:23.532 15152-15354/? E/BluetoothRemoteDevices: getGearIsConnected false
11-14 10:55:23.532 18107-18133/? D/oneconnect[1.6.05-45_2]: BluetoothActionHelper.isConnected - ($)69:D4 NO profile connected
11-14 10:55:23.533 18107-18133/? D/oneconnect[1.6.05-45_2]: BluetoothActionHelper.isA2dpSinkConnected - ($)69:D4 mA2dpSlink not connected
11-14 10:55:23.542 4983-4983/? I/BistoWorker: Not a bisto device: 18:7A:93:4C:69:D4
Ideally when I request for a connection, it should connect with the device. I don't know why android bluetooth is connecting with device without requesting for a connection.
Does anyone have any idea about this?
=========UPDATE==========
Another thing I found is when I tried to connect with the device(scale), it gives me
11-15 14:46:38.473 3770-3770/? D/KnoxKeyguardUpdateMonitor: BroadcastReceiver onReceive action: android.bluetooth.device.action.ACL_CONNECTED
but on my Service it returned following value.
11-15 14:46:38.493 23031-23101/? D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=8 device=18:7A:93:4B:E1:XX
In the case of 133 GATT_FAILURE, I handled it by attempting 4 re-connects. But it still gave 133 error.
Upvotes: 2
Views: 3585
Reputation: 8715
Probably you have autoconnected set to true in your connection request. Be aware that mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
takes as second parameter, the autoconnect
flag.
Please check [connectGatt](https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback)).
Upvotes: 1