Receive channel's poll fails when dicoverServices is called and keeps app stuck
See original GitHub issueWhen we call our device’s deviceConnection.discoverServices()
it calls the method written at line 317 of com/beepiz/bluetooth/gattcoroutines/GattConnectionImpl.kt
, gattRequest
. This method receives a channel (ch: ReceiveChannel<GattResponse<E>>
) for the request purpose and after a few instructions calls ch.reveice()
on this channel. That’s when the problem occours.
The channel throws an error internally the polls fails (as the following print shows) and the exceution goes all the levels up, like when an exception is thrown, but this time without any clue of an error being thrown:
These are the last captured logs:
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: 00:15:90:91:CE:C2, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=5ab39c56-c260-4491-9cac-58843c486207
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=8
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=8 device=00:15:90:91:CE:C2
D/BluetoothGatt: onConnectionUpdated() - Device=00:15:90:91:CE:C2 interval=16 latency=0 timeout=800 status=0
D/BluetoothGatt: onConnectionUpdated() - Device=00:15:90:91:CE:C2 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt: onConnectionUpdated() - Device=00:15:90:91:CE:C2 interval=16 latency=0 timeout=800 status=0
D/BluetoothGatt: discoverServices() - device: 00:15:90:91:CE:C2
D/BluetoothGatt: onSearchComplete() = Device=00:15:90:91:CE:C2 Status=0
I tried to capture any thrown exception around the discoverServices()
call, but the cursor never comes back to my code after that ch.receive()
call.
Issue Analytics
- State:
- Created 4 years ago
- Comments:26 (11 by maintainers)
Top GitHub Comments
My bad, it’s defined in buildSrc/build.gradle.kts
On Wed, Jan 22, 2020, 12:53 Luiz Machado notifications@github.com wrote:
I noticed another place where the same issue happens: when trying to disable remote device characteristic.
While closing my device’s connection, I try to disable notifications from the characteristic I use and, when I call the method, the app gets stuck on the
gattRequest
method fromGattConnectionImpl
. It looks likewriteChannel
(passed down to the method as the first parameter) is expected to return something that never receives on thech.receive()
call on line 333.I don’t know why yet, but I cannot write descriptors at this point.