I'm connecting to BLE device and got two identical onClientConnectionState() calls with identical status. Is this supposed to call multiple times or i doing something wrong? Here the log:
05-06 22:48:31.778 I/BluetoothDevice(17325): createBond() for device D5:...:EA called by pid: 17325 tid: 17360
05-06 22:48:31.813 D/BluetoothGatt(17325): connect() - device: D5:...:EA, auto: false
05-06 22:48:31.814 D/BluetoothGatt(17325): registerApp()
05-06 22:48:31.814 D/BluetoothGatt(17325): registerApp() - UUID=ffbf338d-8200-45f8-83b3-79d71ac40ffd
05-06 22:48:31.816 D/BluetoothGatt(17325): onClientRegistered() - status=0 clientIf=7
05-06 22:48:31.820 D/BluetoothGatt(17325): onClientConnectionState() - status=0 clientIf=7 device=D5:...:EA
Thread started: #7
05-06 22:48:31.835 D/BluetoothGatt(17325): onClientConnectionState() - status=0 clientIf=7 device=D5:...:EA
Thread started: #8
Related
We are working on Android BLE & implemented successfully and it’s working fine with all OS version and devices.
We are able to connect successfully using below code:
mBluetoothDevice.connectGatt(this, true, mGattCallback);
connectGatt
But recently Samsung released Android Oreo(8.0.0) for Samsung Galaxy S9, S9+,S8, S8+ etc devices. Now we are not able to connect with BLE in Samsung devices with Android Oreo using above method. We didn’t get any callback in mGattCallback.
When the autoconnect flag true, the log is:
06-16 14:03:39.666 13724-13724/com.ble D/BluetoothGatt: cancelOpen() - device: DA:32:19:58:63:69
06-16 14:03:39.667 13724-13724/com.ble D/BluetoothGatt: close()
06-16 14:03:39.668 13724-13724/com.ble D/BluetoothGatt: unregisterApp() - mClientIf=0
06-16 14:03:39.792 13724-13724/com.ble D/BluetoothGatt: connect() - device: DA:32:19:58:63:69, auto: true
06-16 14:03:39.793 13724-13724/com.ble D/BluetoothGatt: registerApp()
06-16 14:03:39.793 13724-13724/com.ble D/BluetoothGatt: registerApp() - UUID=f672f50e-d321-4785-9af7-0668e5222970
06-16 14:03:39.797 13724-15182/com.ble D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
But if change the autoconnect flag to false then it’s working.
06-16 14:05:29.486 15681-15681/com.ble D/BluetoothGatt: connect() - device: DA:32:19:58:63:69, auto: false
06-16 14:05:29.487 15681-15681/com.ble D/BluetoothGatt: registerApp()
06-16 14:05:29.487 15681-15681/com.ble D/BluetoothGatt: registerApp() - UUID=a7c4d089-4ba2-422e-b2d1-355d56f6cc8b
06-16 14:05:29.489 15681-16134/com.ble D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
06-16 14:05:30.198 15681-16134/com.ble D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=DA:32:19:58:63:69
06-16 14:05:30.202 15681-16134/com.ble D/BluetoothGatt: discoverServices() - device: DA:32:19:58:63:69
06-16 14:05:30.503 15681-16134/com.ble D/BluetoothGatt: onConnectionUpdated() - Device=DA:32:19:58:63:69 interval=6 latency=0 timeout=500 status=0
06-16 14:05:31.033 15681-16134/com.ble D/BluetoothGatt: onSearchComplete() = Device=DA:32:19:58:63:69 Status=0
06-16 14:05:31.055 15681-16134/com.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 00001734-2927-efef-cdab-eba0fe583711 enable: true
06-16 14:05:31.108 15681-16134/com.ble D/BluetoothGatt: onConnectionUpdated() - Device=DA:32:19:58:63:69 interval=39 latency=0 timeout=500 status=0
When we apply this change it does not connect when the user goes out of range and come again in the range in all devices.
If anyone knows the solutions, please post here.
I have a problem when I try to use cheaper Android phones to communicate with our NordicSemi nRF52832 chip.
I can discover the peripheral and then connect, but when I device.discoverServices() the software pauses for about 10 seconds, and then disconnects with the output:
D/BluetoothGatt: connect() - device: CA:E7:8F:03:82:CE, auto: false
D/BluetoothGatt: registerApp() D/BluetoothGatt: registerApp() -
UUID=b05b54e9-bd20-423f-a6db-461775f954f0 D/BluetoothGatt:
onClientRegistered() - status=0 clientIf=7 D/BluetoothGatt:
onClientConnectionState() - status=0 clientIf=7
device=CA:E7:8F:03:82:CE D/BluetoothGatt: discoverServices() - device:
CA:E7:8F:03:82:CE D/BluetoothGatt: onSearchComplete() =
Device=CA:E7:8F:03:82:CE Status=129 D/BluetoothGatt:
onClientConnectionState() - status=22 clientIf=7
device=CA:E7:8F:03:82:CE D/BluetoothGatt: cancelOpen() - device:
CA:E7:8F:03:82:CE D/BluetoothGatt: close() D/BluetoothGatt:
unregisterApp() - mClientIf=7 D/BluetoothGatt: cancelOpen() - device:
CA:E7:8F:03:82:CE D/BluetoothGatt: close() D/BluetoothGatt:
unregisterApp() - mClientIf=0
With onServicesDiscovered status = 129
The phones are in this case: Samsung Galaxy J3 (J320FN) & Huawei P8lite (ALE-L21)
I'm using RxAndroidBle library for communicating with bluetooth device,
however recently i bumped into strange issue.
When reading one of the device characteristics i receive such error:
BleGattCharacteristicException{macAddress=60:CE:32:BA:9E:70,
status=6 (0x06 -> https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h),
bleGattOperationType=BleGattOperation{description='CHARACTERISTIC_READ'}}
I see that the description states that something is wrong with the characteristic read but I was able to read it on the same device using some commercial scanners or vanilla bluetooth code from google samples.
I checked the characteristic properties - it has PROPERTY_READ.
I bump into same error when using Polidea sample of RxAndroidBle.
Couldn't find similar case anywhere in the internet, maybe someone bumped into such error.
Additional info might be that the device I'm connecting to is a ble device simulator running on an iPhone.
I'm not providing any snippets as I'm using the same code which is in the core examples.
Full verbose log:
06-12 11:00:20.105 22459-22459/? D/RxBle#Radio: QUEUED RxBleRadioOperationConnect(121589482)
06-12 11:00:20.106 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationConnect(121589482)
06-12 11:00:20.131 22459-22459/? D/BluetoothGatt: connect() - device: 41:0A:AE:0E:C2:50, auto: false
06-12 11:00:20.131 22459-22459/? D/BluetoothGatt: registerApp()
06-12 11:00:20.131 22459-22459/? D/BluetoothGatt: registerApp() - UUID=b6c1ef8f-408b-4afb-8e27-97a6ff2c20fb
06-12 11:00:20.137 22459-22473/? D/BluetoothGatt: onClientRegistered() - status=0 clientIf=6
06-12 11:00:20.330 22459-22473/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=41:0A:AE:0E:C2:50
06-12 11:00:20.333 22459-22473/? D/RxBle#BluetoothGatt: onConnectionStateChange newState=2 status=0
06-12 11:00:20.395 22459-22854/? D/CharacteristicOperationExampleActivity: Hey, connection has been established!
06-12 11:00:20.400 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationConnect(121589482)
06-12 11:00:25.608 22459-22459/? I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
06-12 11:00:25.663 22459-22459/? I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
06-12 11:00:25.675 22459-22459/? D/RxBle#Radio: QUEUED RxBleRadioOperationServicesDiscover(3295555)
06-12 11:00:25.676 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationServicesDiscover(3295555)
06-12 11:00:25.683 22459-22459/? D/BluetoothGatt: discoverServices() - device: 41:0A:AE:0E:C2:50
06-12 11:00:25.726 22459-22473/? D/BluetoothGatt: onSearchComplete() = Device=41:0A:AE:0E:C2:50 Status=0
06-12 11:00:25.727 22459-22473/? D/RxBle#BluetoothGatt: onServicesDiscovered status=0
06-12 11:00:25.732 22459-22854/? D/RxBle#Radio: QUEUED RxBleRadioOperationCharacteristicRead(177013014)
06-12 11:00:25.733 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationServicesDiscover(3295555)
06-12 11:00:25.735 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationCharacteristicRead(177013014)
06-12 11:00:25.827 22459-22471/? W/BluetoothGatt: onCharacteristicRead() - Device=41:0A:AE:0E:C2:50 handle=102 Status=6
06-12 11:00:25.830 22459-22471/? D/RxBle#BluetoothGatt: onCharacteristicRead characteristic=1f26b1a4-2b50-11e7-99a8-fcaa142b0bea status=6
06-12 11:00:25.844 22459-22471/? D/RxBle#Radio: QUEUED RxBleRadioOperationDisconnect(84936079)
06-12 11:00:25.849 22459-22471/? D/elo: error: BleGattCharacteristicException{macAddress=41:0A:AE:0E:C2:50, status=6 (0x06 -> https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h), bleGattOperationType=BleGattOperation{description='CHARACTERISTIC_READ'}}
06-12 11:00:25.879 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationCharacteristicRead(177013014)
06-12 11:00:25.880 22459-22504/? D/RxBle#Radio: STARTED RxBleRadioOperationDisconnect(84936079)
06-12 11:00:25.915 22459-22459/? D/elo: error: BleGattCharacteristicException{macAddress=41:0A:AE:0E:C2:50, status=6 (0x06 -> https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.0_r1/stack/include/gatt_api.h), bleGattOperationType=BleGattOperation{description='CHARACTERISTIC_READ'}}
06-12 11:00:25.925 22459-22459/? D/BluetoothManager: getConnectionState()
06-12 11:00:25.925 22459-22459/? D/BluetoothManager: getConnectedDevices
06-12 11:00:25.951 22459-22459/? D/BluetoothGatt: cancelOpen() - device: 41:0A:AE:0E:C2:50
06-12 11:00:25.962 22459-22471/? D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=41:0A:AE:0E:C2:50
06-12 11:00:25.966 22459-22471/? D/RxBle#BluetoothGatt: onConnectionStateChange newState=0 status=0
06-12 11:00:25.971 22459-22459/? D/BluetoothGatt: close()
06-12 11:00:25.971 22459-22459/? D/BluetoothGatt: unregisterApp() - mClientIf=6
06-12 11:00:25.974 22459-22504/? D/RxBle#Radio: FINISHED RxBleRadioOperationDisconnect(84936079)
Verbose log from the Google Bluetooth Sample app in which I can read that property
06-12 14:43:36.540 10869-10869/com.example.android.bluetoothlegatt I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
06-12 14:43:36.598 10869-10869/com.example.android.bluetoothlegatt I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
06-12 14:43:36.599 10869-10869/com.example.android.bluetoothlegatt D/BluetoothLeService: Trying to use an existing mBluetoothGatt for connection.
06-12 14:43:41.209 10869-10869/com.example.android.bluetoothlegatt D/BluetoothAdapter: stopLeScan()
06-12 14:43:41.215 10869-10869/com.example.android.bluetoothlegatt D/BluetoothAdapter: scan not started yet
06-12 14:43:43.781 10869-10882/com.example.android.bluetoothlegatt D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=6 device=5F:56:F7:E9:8A:38
06-12 14:43:43.789 10869-10882/com.example.android.bluetoothlegatt I/BluetoothLeService: Connected to GATT server.
06-12 14:43:43.789 10869-10882/com.example.android.bluetoothlegatt D/BluetoothGatt: discoverServices() - device: 5F:56:F7:E9:8A:38
06-12 14:43:43.792 10869-10882/com.example.android.bluetoothlegatt I/BluetoothLeService: Attempting to start service discovery:true
06-12 14:43:45.513 10869-10882/com.example.android.bluetoothlegatt D/BluetoothGatt: onSearchComplete() = Device=5F:56:F7:E9:8A:38 Status=0
06-12 14:43:54.958 10869-10869/com.example.android.bluetoothlegatt D/BluetoothGatt: setCharacteristicNotification() - uuid: 1f26b1a4-2b50-11e7-99a8-fcaa142b0bea enable: true
06-12 14:43:55.063 10869-10882/com.example.android.bluetoothlegatt W/BluetoothGatt: onCharacteristicRead() - Device=5F:56:F7:E9:8A:38 handle=110 Status=0
There is a difference indeed, as this app is setting a notification before reading a value. The code in app responsible for that looks like this:
// If a given GATT characteristic is selected, check for supported features. This sample
// demonstrates 'Read' and 'Notify' features. See
// http://d.android.com/reference/android/bluetooth/BluetoothGatt.html for the complete
// list of supported characteristic features.
private final ExpandableListView.OnChildClickListener servicesListClickListner =
new ExpandableListView.OnChildClickListener() {
#Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
int childPosition, long id) {
if (mGattCharacteristics != null) {
final BluetoothGattCharacteristic characteristic =
mGattCharacteristics.get(groupPosition).get(childPosition);
final int charaProp = characteristic.getProperties();
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
// If there is an active notification on a characteristic, clear
// it first so it doesn't update the data field on the user interface.
if (mNotifyCharacteristic != null) {
mBluetoothLeService.setCharacteristicNotification(
mNotifyCharacteristic, false);
mNotifyCharacteristic = null;
}
mBluetoothLeService.readCharacteristic(characteristic);
}
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
mNotifyCharacteristic = characteristic;
mBluetoothLeService.setCharacteristicNotification(
characteristic, true);
}
return true;
}
return false;
}
};
As for RxAndroidBle version, I tested it on 1.2.0, 1.2.4 and 1.3.0.
Android versions 7.1, 6.0.1 and 5.1.
Will try to implement this notification before reading characteristic as it's the only difference I can see.
I am receiving the above error on Android BLE app while connecting to my pca10040 based board, and I developed this app with nRF Toolbox as a reference.
I am testing this on multiple Android versions and devices, out of which I dont face any problem on motorolla devic, or nexus device (android 7) or on one plus one with android 6.
I am specifically facing this issue on redmi 3s prime with android 6.0.1. On this device My connection handler will wait for some time and then it throws this error.
I have attached the logs with testing different devices:
**Note : 1 = Connected state
2 = Connecting state
Mi Redme 3s Prime (6.0.1 - Marshmallow)
Result: Fail
04-18 11:56:59.462 8852-8852/com.demo.bledoorlock D/BluetoothGatt: connect() - device: D0:35:52:F8:A9:59, auto: false
04-18 11:56:59.462 8852-8852/com.demo.bledoorlock D/BluetoothGatt: registerApp()
04-18 11:56:59.462 8852-8852/com.demo.bledoorlock D/BluetoothGatt: registerApp() - UUID=dd2097ce-ff94-42e4-a454-4c4401aa5482
04-18 11:56:59.466 8852-8892/com.demo.bledoorlock D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
04-18 11:56:59.467 8852-8852/com.demo.bledoorlock I/System.out: 2
04-18 11:57:00.740 8852-8888/com.demo.bledoorlock V/FA: Inactivity, disconnecting from the service
04-18 11:57:29.490 8852-8992/com.demo.bledoorlock D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=5 device=D0:35:52:F8:A9:59
04-18 11:57:29.491 8852-8852/com.demo.bledoorlock I/System.out: 2
Mi Redme 2 Prime (5.1.1 - Lollipop)
Result: Pass
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock D/BluetoothGatt: connect() - device: D0:35:52:F8:A9:59, auto: false
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock D/BluetoothGatt: registerApp()
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock D/BluetoothGatt: registerApp() - UUID=cb431bbb-bc5e-459b-bdcf-f7ed1929fa01
04-18 11:54:13.871 25251-25580/com.demo.bledoorlock D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
04-18 11:54:13.871 25251-25251/com.demo.bledoorlock I/System.out: 2
04-18 11:54:14.071 25251-25267/com.demo.bledoorlock D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=D0:35:52:F8:A9:59
04-18 11:54:14.071 25251-25251/com.demo.bledoorlock I/System.out: 1
04-18 11:54:14.091 25251-25251/com.demo.bledoorlock D/BluetoothGatt: discoverServices() - device: D0:35:52:F8:A9:59
04-18 11:54:14.091 25251-25251/com.demo.bledoorlock I/ViewRootImpl: CPU Rendering VSync enable = true
04-18 11:54:14.091 25251-25580/com.demo.bledoorlock D/BluetoothGatt: onSearchComplete() = Device=D0:35:52:F8:A9:59 Status=0
04-18 11:54:14.101 25251-25580/com.demo.bledoorlock D/BluetoothGatt: setCharacteristicNotification() - uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: true
Oneplus One (6.0.1 - Marshmallow)
Result: Pass
04-18 11:58:16.768 28661-28661/com.demo.bledoorlock D/BluetoothGatt: connect() - device: D0:35:52:F8:A9:59, auto: false
04-18 11:58:16.768 28661-28661/com.demo.bledoorlock D/BluetoothGatt: registerApp()
04-18 11:58:16.768 28661-28661/com.demo.bledoorlock D/BluetoothGatt: registerApp() - UUID=a3af82f0-c095-4b06-a1fb-479d7d5f715e
04-18 11:58:16.770 28661-28674/com.demo.bledoorlock D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
04-18 11:58:16.777 28661-28661/com.demo.bledoorlock I/System.out: 2
04-18 11:58:17.073 28661-28675/com.demo.bledoorlock D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=D0:35:52:F8:A9:59
04-18 11:58:17.074 28661-28661/com.demo.bledoorlock I/System.out: 1
04-18 11:58:17.086 28661-28661/com.demo.bledoorlock D/BluetoothGatt: discoverServices() - device: D0:35:52:F8:A9:59
04-18 11:58:17.089 28661-28674/com.demo.bledoorlock D/BluetoothGatt: onSearchComplete() = Device=D0:35:52:F8:A9:59 Status=0
04-18 11:58:17.092 28661-28674/com.demo.bledoorlock D/BluetoothGatt: setCharacteristicNotification() - uuid: 6e400003-b5a3-f393-e0a9-e50e24dcca9e enable: true
04-18 11:58:17.159 28661-28697/com.demo.bledoorlock V/RenderScript: 0xaeee3000 Launching thread(s), CPUs 4
04-18 11:58:17.571 28661-28693/com.demo.bledoorlock V/FA: Inactivity, disconnecting from the service
Please suggest how to fix this?
I'm developing app that needs to connect with A&D BP BLE device,I Can able to connect ,disconnect from BLE device,But can't able to get reading ,added full logs here,Please let me know how to proceed further,
09-14 11:03:06.624: D/BluetoothAdapter(9124): startLeScan(): null
09-14 11:03:06.630: D/BluetoothLeScanner(9124): onClientRegistered() - status=0 clientIf=5
09-14 11:03:30.510: D/BluetoothAdapter(9124): stopLeScan()
09-14 11:03:30.523: D/BluetoothGatt(9124): connect() - device: D0:5F:B8:03:79:70, auto: false
09-14 11:03:30.523: D/BluetoothGatt(9124): registerApp()
09-14 11:03:30.523: D/BluetoothGatt(9124): registerApp() - UUID=d0c559ba-1076-4b59-87d3-4547c46810b1
09-14 11:03:30.525: D/BluetoothGatt(9124): onClientRegistered() - status=0 clientIf=5
09-14 11:03:30.528: D/BleService(9124): Trying to create a new connection.
09-14 11:03:30.588: D/BluetoothGatt(9124): onClientConnectionState() - status=0 clientIf=5 device=D0:5F:B8:03:79:70
09-14 11:03:30.588: V/On broadcast Updated.(9124): Entered..com.example.bluetooth.le.ACTION_GATT_CONNECTED
09-14 11:03:30.598: I/BleService(9124): Connected to GATT server.
09-14 11:03:30.598: D/BluetoothGatt(9124): discoverServices() - device: D0:5F:B8:03:79:70
09-14 11:03:30.605: I/BleService(9124): Attempting to start service discovery:true
09-14 11:03:30.607: D/BluetoothGatt(9124): onSearchComplete() = Device=D0:5F:B8:03:79:70 Status=0
09-14 11:03:30.607: D/BleService(9124): onServicesDiscoverd
09-14 11:03:30.607: V/BleService(9124): on service discovered Status 0=0
09-14 11:03:30.607: D/BleService(9124): 0
09-14 11:03:30.622: D/MainAct(9124): com.example.bluetooth.le.ACTION_GATT_CONNECTED
09-14 11:03:30.627: D/BloodPressureMeasurement(9124): setIndication
09-14 11:03:30.627: D/BloodPressureMeasurement(9124): Service Not Null
09-14 11:03:30.627: D/BloodPressureMeasurement(9124): Characteristic Not Null
09-14 11:03:30.627: D/BluetoothGatt(9124): setCharacteristicNotification() - uuid: 00002a35-0000-1000-8000-00805f9b34fb enable: true
09-14 11:03:30.637: D/BloodPressureMeasurement(9124): Characteristic Status isSuccess : true
09-14 11:03:30.637: D/BloodPressureMeasurement(9124): make descriptor enable : true
09-14 11:04:00.574: D/BluetoothGatt(9124): onClientConnectionState() - status=22 clientIf=5 device=D0:5F:B8:03:79:70
09-14 11:04:00.574: I/BleService(9124): Disconnected from GATT server.
09-14 11:04:00.574: V/On broadcast Updated.(9124): Entered..com.example.bluetooth.le.ACTION_GATT_DISCONNECTED
09-14 11:04:00.607: D/MainAct(9124): com.example.bluetooth.le.ACTION_GATT_DISCONNECTED
After Calling **gatt.writeDescriptor(descriptor);**app is returning below logs
09-14 11:04:00.574: D/BluetoothGatt(9124): onClientConnectionState() - status=22 clientIf=5 device=D0:5F:B8:03:79:70
09-14 11:04:00.574: I/BleService(9124): Disconnected from GATT server.