Giter VIP home page Giter VIP logo

Comments (2)

philips77 avatar philips77 commented on July 17, 2024

Hi @lukecorbin,
So my guess would be, that you have another app connected to the same device on your phone. For example, nRF Connect likes to connect in the background. But if you are working with HID device it may be the system Bluetooth app, or any other, that's using Bluetooth. Some time ago we heard rumors about Spotify app that was holding a connection. Calling disconnect() just closes your local virtual connection. The system will terminate the physical connection one second after the last virtual was closed.
You may actually have multiple virtual connections in your app, if you call device.connectGatt(...) many times. Each time you are given a new instance of BluetoothGatt, but they are all equally good and may be used in different parts of your app. Disconnecting form one doesn't disconnecting others.

As to the other issue. Android can even connect to BLE devices when the Bluetooth is off. It's just says it's off, while it's not fully true. Android is using it to increase location accuracy, etc. You can't scan with Bluetooth off, but connecting may be possible on some phones, including Pixels. nRF Connect doesn't allow to do this, but that's implemented behavior. And it should be enough to start Airplane Mode to make them disconnect, no need to restart.

The solution, if you really need to make the device disconnected, is to trigger the disconnection from the peripheral side. This can be done, for example, by sending some specific command from the phone and waiting for status change.
I may to add "WaitForDisconnect" request to this library for that purpose. I have to think about it.

from android-ble-library.

philips77 avatar philips77 commented on July 17, 2024

Task created in #51. Closing this one. If my above solution didn't help you, feel free to open it again.

from android-ble-library.

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.