Comments (6)
Nice catch, so maybe we need to purge the Gatt objects?
from blue-falcon.
I would start with setting references to null. Calling close and disconnect or searching for more solutions. This is clearly issue with android bt stack since internet is full of posts about ble issues :) shame that we need to do something with this not google. Kudos for Apple for better BT stack. If you provide some branches to test i will do stress tests ASAP (between 5am and 2pm :) )
from blue-falcon.
I can reproduce the exact same issue.
I have tried to investigate a little bit, e.g. have a look on following link .
"As previously stated, the problem is caused by calling connectGatt multiple times. Each one of those calls create a new BluetoothGatt instance and they are all kept alive, while you have only the last one. Given the fact that sometimes it is needed to call connectGatt multiple times, I just keep all the instances that it returns and call disconnect/close on all of them when I'm done. "
Possible solution for this could be storing all BluetoothGatt objects returned by method connectGatt() in a list and on device disconnection, try to trigger disconnect() + close() on all of these BluetoothGatt objects, not only on one that is returned by mGattClientCallback.gattForDevice() .
from blue-falcon.
I think that solution from @PeterKucera might work, worth a try
from blue-falcon.
Hi all,
I have done some tests and tried to modify the library.
It looks like approach mentioned in my previous comment will not fix the issue.
However, it looks like the issue could be calling close() method right after disconnect() method - when I added some delay between these 2 method calls, I cannot reproduce the issues I previously had, and therefore it looks like GATT connection is closed properly.
Please @felislynx-silae can I ask for retesting using this fix ?
https://github.com/PeterKucera/blue-falcon/commit/67eb76776e1100e2168f3c176460500d45ee18d4
Edit - After some additional testing (50+ requested connections in a loop) I can still reproduce reported issue (device is not responding and only turning BT on/off or reseting peripherial will resolve the issue). However, I would still suggest adding 500 ms delay between disconnect() and close(), because without this delay disconnect() is not working properly for me. I am working on functionality that dynamically initializes devices, and literally without this 500ms delay re-initialization of device fails everytime. I can open open new issue and provide more proof if neccessary.
Edit 2 - I tried to have a look on other BLE libraries, they have to face the similar issues, right ?
"This is OS related problem. There is nothing can be done afaik. Their BLE stack is probably getting off and there is no programmatic way that could ensure proper functionality. You could try turning off/on the Bluetooth Adapter and Wifi (on <=6.0)"
Source : dariuszseweryn/RxAndroidBle#688 (comment)
from blue-falcon.
@PeterKucera I've tested your commit. It is not fixing this issue. Currently only working solution is nulling all references to BlueFalcon and recreate object
from blue-falcon.
Related Issues (20)
- BluetoothGatt: android.os.DeadObjectException
- Cannot build KotlinMP example HOT 9
- Add support for manufacturerSpecificData (Android) and kCBAdvDataManufacturerData (iOS) HOT 1
- Add support for new Kotlin IR HOT 7
- kmm example - iOS App crashes HOT 1
- changeMTU() method does not work as expected HOT 2
- Update to Kotlin v1.4.21 HOT 1
- KMM example doesn't work on android 10+
- iOS App throws "kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one." HOT 5
- Non-null service UUID constructor parameter removes all scan results for iOS HOT 2
- No such module 'BlueFalcon' HOT 11
- Windows 10 platform support HOT 7
- Byte array values are not properly converted on iOS HOT 1
- The characteristic value change delegate never fire HOT 11
- Latest release failing due to no xcode 13 support on github HOT 14
- BlueFalcon not found in iOS HOT 12
- Kotlin KMM dev.bluefalcon.BluetoothUnknownException: Unknown error happened HOT 15
- The project 'blue-falcon' is not a Gradle-based project HOT 17
- Notify not working on Android HOT 6
- Second disconnect not working (Android) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blue-falcon.