Skip to content
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

Writing characteristic not working after reconnect. #50

Open
kazyh opened this issue Aug 24, 2020 · 3 comments
Open

Writing characteristic not working after reconnect. #50

kazyh opened this issue Aug 24, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@kazyh
Copy link

kazyh commented Aug 24, 2020

Issue created with #45 fix.
After disconnect by calling disconnect method and reconnect again with device within same BlueFalcon instance, we won’t be able to write to gatt characteristic.

It is because when we close the gatt connection in disconnect method, the method onConnectionStateChange from BluetoothGattCallback will never be called and as a result removeGatt method won’t be called. Thus the item in the Gatt list is not removed. In such cases when trying to write a characteristic we take an old object which is not currently connected to the device.

In my opinion there are two solutions
add additional call of removeGatt in disconnect method
moving close() method from disconnect to onConnectionStateChange in BluetoothGattCallback so gatt will be closed after remove.

First solution should work properly but it is not that clean and neat.
Second is better but You need to check if moving close method won’t be an issue in disconnect scenarios and in that case You need to remove delegates.forEach { it.didDisconnect(bluetoothPeripheral) } from disconnect method to avoid calling it twice. This solution need to be tested very carefully.

@Reedyuk
Copy link
Owner

Reedyuk commented Aug 24, 2020

hmm, second would be better. I think we should try it and see if it doesnt break anything.

@Reedyuk Reedyuk added the bug Something isn't working label Apr 7, 2022
@dishank-betaflux
Copy link

Any updates on it?

@Reedyuk
Copy link
Owner

Reedyuk commented Sep 24, 2022

No update yet, but if you want to put a pr in, would happily review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants