-
Notifications
You must be signed in to change notification settings - Fork 442
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
Connect after Disconnect Error #50
Comments
The error is about connection, rather than canceling or disconnecting. See #18 and especially my last comment there, where I listed possible problems causing the issue. If you are sure that all the problems listed in the comment are not your case, please feel free to ask for further help here. BTW,
Does it mean, that you are immediately creating another connection just after closing the previous one? You might want to |
Dear @PsychoXIVI |
actually it never get out of this await connection.cancel(); |
I added button to floatingActionButton: FloatingActionButton(
onPressed: () {
print('TEST: canceling the connection');
connection.cancel().then((_) {
print('TEST: connection cancelled');
});
},
child: Icon(Icons.cancel),
),
If it is not working in your case, I think you should modify /// Closes connection (rather immediately), in result should also disconnect.
Future<void> cancel() async {
print('TEST: cancel - entered');
await output.close();
print('TEST: cancel - output closed');
await _readStreamController.close();
print('TEST: cancel - read stream controller closed');
await _readStreamSubscription.cancel();
print('TEST: cancel - read stream subscription closed]');
} You can use this modification by changing your dependency to:
Note: that is temporary branch, after solving issue you should change it back to normal After applying the more logging, please share the log after using the
Well, it looks like small bug, just lack of additional check for the situation, when user disables the Bluetooth while already connection ongoing. I think it may not be related to the main problem, but for sure I will do something about it in the future. For now you can also listen to Bluetooth adapter status changes to determine when user is turning off the adapter. I am still looking for other possibilities, that could cause the main issue happen. Could you confirm, that you are using both input and output of the connection? Are they are working fine? |
Dear @PsychoXIVI Using the official repository I got the follow response:
But actually it doesnt disconnect it. When I try to reconnect after few minutes I got the message:
But... Using your git branch fix the issue!!! Great work!!! Do you have any plan to release new plugin version? Thank you again!! |
That sound great. I think I understand what went wrong: There was #48 PR fixing some disconnection problem - and it isn't already at official package release. I will prepare v0.2.1 ASAP, to include that important fix. I'm sorry for procrastination - I should release the patch versions more often. |
Published patch version 0.2.1. You should update your I am closing the issue by now. Let me know in case is there something wrong with the patch version. |
Trying to make a simple test with this lib connecting to a BT printer.
on log I got the message:
D/FlutterBluePlugin(15353): Disconnected (id: 14)
But when I try to execute the same code it gives me the follow error:
Looks like it doesnt close the connection.
Any clue how to fix it?
Thanks
The text was updated successfully, but these errors were encountered: