Code Monkey home page Code Monkey logo

Comments (10)

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

Thank you for the suggestion. We will considerate it. Unfortunately we're currently occupied with different things.

You're always welcome to make a Pull Request. :)

from rxandroidble.

farmazon3000 avatar farmazon3000 commented on July 30, 2024

This refresh may be the last resort for problems like #49.

from rxandroidble.

s1155030742 avatar s1155030742 commented on July 30, 2024

This refresh is essential for any kind of function that involve change of characteristic during reconnection. I believe the framework can be much more powerful if "refresh" is supported

from rxandroidble.

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

@s1155030742 I did not had a need for using the refresh function. Could you describe or paste link to a place where the usage is described? Should the method be called when the connection is active/disconnected/closed? What exactly the method does?

from rxandroidble.

kenwdelong avatar kenwdelong commented on July 30, 2024

Use of this method is discussed here: http://stackoverflow.com/questions/22596951/how-to-programmatically-force-bluetooth-low-energy-service-discovery-on-android

Basically, some phones cache the list of services and characteristics between connections. So if the device has changed it's services or characteristics since you last connected, you can have fatal errors. The refresh() method will clear the phone's cached list.

Based on the code samples and how I understand that it works, I think refresh() would have to be called after connection but before service discovery starts.

I just got bit by this this morning, connections are failing left and right. Is there a way to get hold of the native BluetoothGatt so I can implement the fix described in the Stack Overflow until this feature can be implemented?

from rxandroidble.

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

@kenwdelong You could try to use <T> Observable<T> queue(RxBleRadioOperationCustom<T> operation); function.

from rxandroidble.

kenwdelong avatar kenwdelong commented on July 30, 2024

Yes! Thank you!

from rxandroidble.

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024

To all interested people:
What is the supposed scenario for calling BluetoothGatt.refresh()?

  1. Call it at the beginning of the connection
  2. Call it in the middle of the connection
  3. Call it at the end of the connection

The last option looks to be the most bulletproof in terms of implementation. The first one seems also to be doable and should not require a big amount of work. The second does look like a pain to implement as some Observables that could have beed created / subscribed before refreshing could stop working properly.

Any information about the use-cases for this is valuable! :)

from rxandroidble.

Rioner123 avatar Rioner123 commented on July 30, 2024

Hi all, just ran into this problem now! The bluetooth connection on my device disables and I cannot re-enable it unless I flush the data/cache of the bluetooth process. The only way to do this is to call BluetoothGatt.refresh();

Problem 1. Bluetooth is currently disabled and I need to be able to run the refresh method first (because I don't have a valid connection)

Regarding best scenario for calling BluetoothGatt.refresh(), I would personally prefer at the beginning of the connection.
Reasoning: It's the only predictable place where I can reliably call it.

from rxandroidble.

kenwdelong avatar kenwdelong commented on July 30, 2024

For us, our device can be in normal "application" mode or in "dfu" (direct firmware upgrade) mode. In dfu mode, the list of services and characteristics is a subset (generally) of what's available in application mode. So, for example, if the device is scanned in dfu mode, and the phone caches the results of service discovery, then even if the device has returned to application mode it can't be accessed because the phone does not believe that the required characteristics exist (and vice versa).

I really don't know when is the best time to refresh. Just after connecting and before service discovery, or just before or after connecting. I doubt that refreshing in the middle of the connection is a good idea.

The Nordic DFU Upgrade library, I think, disconnects but then before it releases the BluetoothGatt object it invokes the refresh() function. That's probably a pretty safe option.

from rxandroidble.

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.