Code Monkey home page Code Monkey logo

Comments (5)

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

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.

Ibrahimhassan1 avatar Ibrahimhassan1 commented on July 30, 2024

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.

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

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.

farmazon3000 avatar farmazon3000 commented on July 30, 2024

status 8 is a timeout error as far as I know where do you know that from?

from rxandroidble.

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.