-
Notifications
You must be signed in to change notification settings - Fork 71
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
Android device disconnect error #115
Comments
If I set: QuickBlue.setServiceHandler(_handleServiceDetect);
QuickBlue.setValueHandler(_handleBleData); then on second connection I get two connection events. If I set null after first disconnect, I get single connection event (from quick blue). I'm not sure what to make of this. |
Your device disconnected itself somehow Android phone and BLE API stacks have a lot of problems. You have to figure it out yourself, probably authentication or configuration(i.e. MTU negotiation) failure |
Thanks for the article. Looks like good info for another issue I have on the server device. I solved the issue. On disconnect I had to do: await QuickBlue.setNotifiable(
_peripherals[_connectedMachine].deviceId, BLE_SERVICE_UUID, BLE_CHARACTERISTIC_UUID, BleInputProperty.disabled); I noticed the issues were occurring approximately after the call to set: QuickBlue.setNotifiable(
deviceId, BLE_SERVICE_UUID, BLE_CHARACTERISTIC_UUID, BleInputProperty.notification); so on a hunch I disabled (just before) on disconnect and yeah... So I guess the final step to closing this would be:
|
I'm not sure about your point If devices disconnected, no need to |
I mean that I have to set that before I disconnect the device, or quick_blue somehow ends up with duplicated incoming events. If I force a disconnect by turning the machine off, then I can't do
the machine BLE is fine. It was working well in test env, LightBlue connection test, and in the previous "flutter reactive ble". In the log above you can see I get duplicated By force disconnect I mean I power-off the machine. And this really is not an issue with our BLE devices. I'm sorry I can't do much to debug this as I don't know kotlin. But it really does seem as if a stream or channel isn't closing, or being duplicated. |
Is it at all possible that the |
val gatt = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
remoteDevice.connectGatt(context, false, gattCallback, BluetoothDevice.TRANSPORT_LE)
} else {
remoteDevice.connectGatt(context, false, gattCallback)
}
knownGatts.add(gatt)
And |
According to https://stackoverflow.com/questions/34158315/clientif-field-in-android-bluetoothgatt-class, |
Not in my code at least. I verified making sure that only one scan was ever run, and purged the result list after scans. Same result as before, if I yank machine power I get a disconnect then on reconnect there's that same Forcing myself to learn some kotlin through this... I'm baffled by the issue. It actually looks to still be something to do with knownGatts is a list right? Forcing myself to learn some kotlin as I go along here... My working theory is maybe that's related or is the issue...
That doesn't seem likely from what I've read though.. How would I end up with previous scan results in the stream but only if it's an unexpected disconnect? Looking at
then on third connection after (two) unexpected disconnect I get this order
somehow the previous result is being held and sent... out of order? Setting `QuickBlue.setConnectionHandler(null) on disconnect in app then back to handler on connect action also doesn't help. In app, stopscan cancels the scan result listener.. Stopping or starting has no effect on the above issue. I'm almost ready to believe it's related to |
A side note: flutter_reactive_ble sets the notification to off/disabled on disconnect automatically:
|
A little curious how it is done. I've not idea how to disable notification after disconnected |
I don't know sorry. This seems to narrow down to: Connect:
Unexpected disconnect:
Reconnect:
I see that the last line is the state from first connection. The reconnect happens after a re-scan... The re-scan I have removes previous scan results if they are not found again. So when the unexpected disconnect happens, the previous ( Update: I removed the bit where previous result is removed. There is no difference. I've rewritten a huge chunk of code in a few different ways to narrow this down as much as I can, and it looks like Oh and curiously:
It happens even if the scan is left running. I've gone the nuclear option and on disconnect completely destroy and replace the service part of my code that deals with BLE, still no change. I can't replicate this issue using the example scan app either. I'm at a loss. |
Hi, I have the same issue with the duplicated handleValueChange events after enabling a notification. Edit: Replacing |
On Disconnect (Android) there is an error
|
hey @flukejones @GorIvanov @Sunbreak @TomixUG can u guys please provide any working example of this package in android. I have tried but it's give permission exception all the time |
First connection
Disconnect shows two events and two failures
Now I have two streams on re-connect.
I don't know how on earth I'm getting two disconnection events. But regardless, I end up with 2 or more streams outputting to the handlers on reconnection. The same happens for if I turn the device off and reconnect.
I don't get these issues on iOS.
The text was updated successfully, but these errors were encountered: