Code Monkey home page Code Monkey logo

Comments (6)

Reedyuk avatar Reedyuk commented on August 23, 2024

Nice catch, so maybe we need to purge the Gatt objects?

from blue-falcon.

felislynx-silae avatar felislynx-silae commented on August 23, 2024

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.

PeterKucera avatar PeterKucera commented on August 23, 2024

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.

felislynx-silae avatar felislynx-silae commented on August 23, 2024

I think that solution from @PeterKucera might work, worth a try

from blue-falcon.

PeterKucera avatar PeterKucera commented on August 23, 2024

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.

felislynx-silae avatar felislynx-silae commented on August 23, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.