Comments (5)
Hello there,
Can you share which BLE device you're connecting to?
D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=5 device=C4:xx:xx:xx:0A:9F
-> status 8 is a timeout error as far as I know and it seems that your BLE device is stopping to keep the connection alive.
The error comes from the Android Bluetooth API and the RxAndroidBle cannot really do much about it.
Perhaps you're forgetting to set some configuration on your BLE device that would make it to continue the connection?
Best Regards
from rxandroidble.
The device that I connect is a BlendMicro (http://redbearlab.com/blendmicro/).
Before I try RxAndroidBle I used to enable notifications using the following snippet and it didn't have any affect on the connection; so i doubt that the problem is with the Ble device:
// enable notifications
BluetoothGattCharacteristic characteristicRX = gatt.getService(Constants.UUID_BLE_SHIELD_SERVICE).getCharacteristic(Constants.UUID_BLE_SHIELD_RX);
setCharacteristicNotification(gatt, characteristicRX, true);
/**
* Enables or disables notification on a give characteristic.
*
* @param characteristic Characteristic to act on.
* @param enabled If true, enable notification. False otherwise.
*/
public void setCharacteristicNotification(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic, boolean enabled) {
if (gatt == null) {
Log.w(LOG_TAG, "BluetoothAdapter not initialized");
return;
}
if (characteristic != null) {
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 (gatt.equals(mGatt)) {
if (mNotifyCharacteristic != null) {
gatt.setCharacteristicNotification(
mNotifyCharacteristic, false);
mNotifyCharacteristic = null;
}
}
gatt.readCharacteristic(characteristic);
}
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
if (gatt.equals(mGatt)) {
mNotifyCharacteristic = characteristic;
}
gatt.setCharacteristicNotification(characteristic, enabled);
if (Constants.UUID_BLE_SHIELD_RX.equals(characteristic.getUuid())) {
BluetoothGattDescriptor descriptor = characteristic
.getDescriptor(UUID
.fromString(Constants.CLIENT_CHARACTERISTIC_CONFIG));
descriptor
.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(descriptor);
}
}
}
}
Is there a way to apply that snippet using the RxLibray?
As you mentioned Status 8 is a timeout error, what is the scenario that should happen after enabling the notifications? does the remote device need to send something back to the app?
What configuration are you suggesting to check?
from rxandroidble.
Correct me if I am wrong - you're not getting any notifications about the changes from the device even though you should. Am I right? If yes - could you also paste the code that you use for setting up the notification?
from rxandroidble.
status 8 is a timeout error as far as I know
where do you know that from?
from rxandroidble.
I was digging through the documentation and issues that people encountered. I have double checked and found out that I was wrong. Actually status 8 is "Insufficient authorization". Probably you should have bonded device.
Here are some status codes that may be useful: https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.4.4_r2.0.1/stack/include/gatt_api.h
Currently RxAndroidBle doesn't help in support of bonded devices / encrypted connections. Pull Requests are encouraged though. ;)
from rxandroidble.
Related Issues (20)
- It is not possible to disconnect the Bluetooth while it is in the process of connecting. HOT 1
- BleGattCharacteristicException while readCharacteristic HOT 12
- scanResult.bleDevice.name not showing Ble updated name HOT 1
- BLUETOOTH_SCAN set usesPermissionFlags="neverForLocation",Is there a problem? HOT 2
- GenericFailure<CharacteristicValueUpdateError> HOT 11
- Send long bytes twice HOT 2
- Write request is not processed in the random order HOT 2
- Long Bytes Send HOT 8
- Creating a Fork HOT 2
- Set Preferred PHY / Read PHY HOT 2
- RxBleClient mulit connections HOT 4
- Is the library still maintained? HOT 3
- Android 14 breaking change HOT 15
- Google Pixel 5 loses bonding info after BT adapter cycle HOT 4
- Metode readcharacteristic not stream HOT 2
- Unable to readCharacteristic after writeCharacteristic HOT 5
- In the case of unsuccessful Bluetooth connection, actively disconnect without executing context. unregisterReceiver (receiver); At this point, there may be multiple Bluetooth broadcast registrarReceivers, which may crash on some Huawei phones due to a broadcast limit of approximately 1000. Suggest fixing this issue. HOT 2
- Can't scan after connect dispose/clear HOT 1
- Add `advertisingSid` property to `ScanResult` and `RxBleInternalScanResult` HOT 3
- BleGattCallbackTimeoutException when writing a characteristic with different data payload many times in a short period of time. HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxandroidble.