Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when initializing a weak connection #7

Closed
peabody124 opened this issue Apr 12, 2018 · 2 comments
Closed

Crash when initializing a weak connection #7

peabody124 opened this issue Apr 12, 2018 · 2 comments

Comments

@peabody124
Copy link
Contributor

peabody124 commented Apr 12, 2018

When my device is just on the edge of range and ultimately probably won't establish a reliable connection I get this error stack from the Android-BLE-Library:

04-12 16:53:03.586 8991-9590/org.sralab.emgimu W/BluetoothGatt: Unhandled exception in callback
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothDevice android.bluetooth.BluetoothGatt.getDevice()' on a null object reference
        at no.nordicsemi.android.ble.BleManager$BleManagerGattCallback.onDeviceReady(BleManager.java:1276)
        at no.nordicsemi.android.ble.BleManager$BleManagerGattCallback.nextRequest(BleManager.java:1734)
        at no.nordicsemi.android.ble.BleManager$BleManagerGattCallback.nextRequest(BleManager.java:1834)
        at no.nordicsemi.android.ble.BleManager$BleManagerGattCallback.nextRequest(BleManager.java:1834)
        at no.nordicsemi.android.ble.BleManager$BleManagerGattCallback.onCharacteristicRead(BleManager.java:1550)
        at android.bluetooth.BluetoothGatt$1$6.run(BluetoothGatt.java:364)
        at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:725)
        at android.bluetooth.BluetoothGatt.-wrap0(Unknown Source:0)
        at android.bluetooth.BluetoothGatt$1.onCharacteristicRead(BluetoothGatt.java:358)
        at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:124)
        at android.os.Binder.execTransact(Binder.java:697)

In my case I get a link loss callback so I close the BleManager. This sets the GattCallback to null. It seems like when the BleManager is in this state, it should not attempt to go through the initialization requests.

@peabody124
Copy link
Contributor Author

As an aside this is me probably using this slightly improperly. I realized that with autoConnect true I should let it fail to reconnect and then close out the connection. Still it probably should be safe for this behavior.

@peabody124
Copy link
Contributor Author

Note my "workaround" a.k.a. using it correctly probably, is to call disconnect() before close(). This is even when onDeviceConnected / onDeviceReady never fired -- just onDeviceConnecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants