Closed FritzMatthaeus closed 1 year ago
hm, it's getting weird. Now i get a 'disconnect error: device is not connected' message when calling disconnect. The device is sill connected though:
I/ViewRootImpl@95a8c2a[MainActivity](29334): ViewPostIme pointer 0
I/ViewRootImpl@95a8c2a[MainActivity](29334): ViewPostIme pointer 1
I/flutter (29334): [FBP] <disconnect> args: 6C:1D:EB:04:AA:78
D/[FBP-Android](29334): [FBP] onMethodCall: disconnect
D/[FBP-Android](29334): [FBP] disconnect: canceling connection in progress
D/BluetoothGatt(29334): cancelOpen() - device: 6C1DEB_8
D/BluetoothGatt(29334): onClientConnectionState() - status=0 clientIf=7 device=6C1DEB_8
I/flutter (29334): [FBP] <disconnect> result: true
D/[FBP-Android](29334): [FBP] onConnectionStateChange: status: 0 (SUCCESS) newState: disconnected
D/BluetoothGatt(29334): close()
D/BluetoothGatt(29334): unregisterApp() - mClientIf=7
I/flutter (29334): [FBP] [[ OnConnectionStateChanged ]] result: {disconnect_reason_code: 0, disconnect_reason_string: SUCCESS, remote_id: 6C:1D:EB:04:AA:78, connection_state: 0}
[FBP] disconnect: canceling connection in progress
edit: this log was due to a simple unrelated bug. fixed in 1.29.10
@FritzMatthaeus , disconnect
only disconnects our app. if another app is connected it will still be connected to other apps AFAIK.
@FritzMatthaeus ,
disconnect
only disconnects our app. if another app is connected it will still be connected to other apps AFAIK.
Hi,
That's a good point. Any idea on how to fully disconnect the device, as i need to really disconnect? It must be possible somehow, even if it hasn't been implemented yet.
I haven't found out yet, how to debug the native java code of the flutter project to fully investigate all the methods of BluetoothGatt.
It must be possible somehow, even if it hasn't been implemented yet.
I've tried BluetoothGatt.close() but this did not work.
no i don't think that is possible.
your app is not allowed to control other apps connections.
you might be able to disconnect in Settings. So you can instruct the user to go into the settings app perhaps.
no i don't think that is possible.
your app is not allowed to control other apps connections.
But i can disconnect a connection established in a FBP Demo App with the NrfConnect App. So obviously it is possible somehow.
My FBP is the only app establishing the connection, still i cannot disconnect the smartphone from the device.
Another explanation might be, that unintentionally there is more than one gatt instance created by FBP so disconnecting would disconnect the one instance but there is still another one alive. But even in this scenario i am able to disconnect via nRFConnect App.
thanks testing it.
Im not sure what the issue could be then.
If you figure out more details let me know.
by the way, disconnect
works on Android 13 fine for me.
When I press disconnect in the example app, it disconnects in the device firmware.
Hi,
yes, it works fine. The reason for the problem has been multiple native GATT-Instances with the same Device. As you can only disconnect one via the App, the Connection stays alive as further Instances are connected. I assume, this happened as i used the hot reload feature while beeing connected and this might have created new Instances with the same device. But i cannot exclude that this might be a bug in the library. This might need further inspection
if you find reliable repro steps, please open a new issue.
It can be finally closed as i could reproduce it. I have the nRFConnect App installed for testing purposes. When establishing the connection via my FBP-App i get asked in a notification if i wanted to debug the connection with the nRFConnect App. If i click "yes" (which i did, as i did not pay attention to it), it will establish a GATT-Instance in nRF-Connect so disconnecting in my FBP-App will not fully disconnect the device. So this is a special case when debugging with nRF-Connect
Requirements
Have you checked this problem on the example app?
Yes
FlutterBluePlus Version
1.29.8
Flutter Version
3.16.1
What OS?
Android
OS Version
Android 13
Bluetooth Module
ANNA-B112
What is your problem?
I can successfully connect my Samsung A53 to the Bluetooth Device as i can see in it's logs. When calling disconnect via FBP, i get a success message from FBP but the connection is still alive. I do not get a disconnect message in the Bluetooth device logs and when checking the connection with the NrfConnect App i can see, that the connection is still alive.
If i connect and disconnect to the Device via the NrfConnect App it successfully get's connected and disconnected. So this problem is related to FBP and not to the Bluetooth Device.
Logs