NordicSemiconductor / Android-BLE-Library

A library that makes working with Bluetooth LE on Android a pleasure. Seriously.
BSD 3-Clause "New" or "Revised" License
1.98k stars 413 forks source link

Null reference exception when calling disconnect #535

Closed david-gettins closed 6 months ago

david-gettins commented 9 months ago

I have recently updated to v2.7.2 amongst other oddities I have found disconnect throws a NullPointerException every time I call it.

To Reproduce

Notes

The peripheral is disconnected despite the NullPointerException. I verified this by scanning for it after disconnect and seeing the error.

david-gettins commented 9 months ago

Here is the stack trace up to the point were it hits my code:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.BluetoothGattServer.cancelConnection(android.bluetooth.BluetoothDevice)' on a null object reference
                at no.nordicsemi.android.ble.BleServerManager.cancelConnection(BleServerManager.java:190)
                at no.nordicsemi.android.ble.BleManagerHandler.internalDisconnect(BleManagerHandler.java:746)
                at no.nordicsemi.android.ble.BleManagerHandler.nextRequest(BleManagerHandler.java:3495)
                at no.nordicsemi.android.ble.BleManagerHandler.enqueue(BleManagerHandler.java:1550)
                at no.nordicsemi.android.ble.Request.enqueue(Request.java:1209)
                at no.nordicsemi.android.ble.TimeoutableRequest.enqueue(TimeoutableRequest.java:106)
                at no.nordicsemi.android.ble.ktx.RequestSuspendKt.suspendCancellable(RequestSuspend.kt:406)
                at no.nordicsemi.android.ble.ktx.RequestSuspendKt.suspend(RequestSuspend.kt:40)
david-gettins commented 9 months ago

For now I have downgraded to v2.6.1 and the exception is not thrown. I haven't tried v2.7.0 or v2.7.1.