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

Two rxBleClient instances to handle two devices simultaneously #250

Closed
filipradon opened this issue Jul 14, 2017 · 5 comments
Closed

Two rxBleClient instances to handle two devices simultaneously #250

filipradon opened this issue Jul 14, 2017 · 5 comments
Assignees
Milestone

Comments

@filipradon
Copy link

Summary

It’s not exactly an issue, more like a architecture-ish question.
Basically in app, we perform some kind of a real time control on two ble devices simultaneously.
Ble operations are performed very fast so as long there are no errors everything works smoothly.
The problem appears when one of the two devices vanish, and operation hangs. It’s waiting for a timeout, and all the operations from the
second device are waiting in the queue.
We were able to overcome this issue by adding second rxBleClient so every client handles communication with single device.
However, in all Your docs You strongly emphsise that there should only be one rxBleClient instance in app.
Basically the question is:
is there any way to handle two devices using one rxBleClient without problem I described before?
If not, are there any crucial downsides of using two rxBleClients?

Thanks in advance for any feedback!

@dariuszseweryn
Copy link
Owner

dariuszseweryn commented Jul 17, 2017

Hello @Jogosb
The single RxBleClient instance is recommended because it is serializing all bluetooth actions to make the experience more stable. It is possible that the library serializes too much when it comes to multiple connections but it was not tested and the experience may vary between implementations of the BLE stack from different phone vendors. This use-case is not defined / documented in any way.

is there any way to handle two devices using one rxBleClient without problem I described before?

Unfortunately no — currently it is not possible

If not, are there any crucial downsides of using two rxBleClients?

It is not tested in any way and you may experience weird behaviour / bugs.

For sure actions on a single BluetoothGatt are needed to be synchronized or the next action will not start (i.e. BluetoothGatt.readCharacteristic(BluetoothGattCharacteristic) will return false unless the previous action will finish with a corresponding BluetoothGattCallback). If you could test if actions on two or more BluetoothGatts have to be serialized in the same way as on a single BluetoothGatt if would be great and could make the library better.

Best Regards

@dariuszseweryn dariuszseweryn self-assigned this Jul 17, 2017
@dariuszseweryn dariuszseweryn added the question / library Issue containing question / discussion about library workings label Jul 17, 2017
@hoanglm4
Copy link

I using 4 RxBleClient for connect 4 device in the same time. Currently, I do see anything problem.

@dariuszseweryn dariuszseweryn added enhancement and removed question / library Issue containing question / discussion about library workings labels Aug 3, 2017
@dariuszseweryn dariuszseweryn added this to the 1.4.0 milestone Aug 3, 2017
dariuszseweryn added a commit that referenced this issue Aug 3, 2017
(#250) It was found that commands from different `BluetoothGatt`’s are synchronized so it is possible to decouple synchronization of commands for different connections. Thanks to that if there are two or more connections opened and one connection would get stalled — other connections may continue to work without stalling — with a single command queue shared between connections it was not possible.
dariuszseweryn added a commit that referenced this issue Aug 30, 2017
(#250) It was found that commands from different `BluetoothGatt`’s are synchronized so it is possible to decouple synchronization of commands for different connections. Thanks to that if there are two or more connections opened and one connection would get stalled — other connections may continue to work without stalling — with a single command queue shared between connections it was not possible.
@dariuszseweryn
Copy link
Owner

I have just merged a pull request that should make additional RxBleClient's obsolete — now the same behaviour should be possible to get with only just one. Handling of multiple connections should now be better — stalling of one connection should not interact with others.

The change should be available in 1.4.0-SNAPSHOT shortly.

Best Regards

@hoanglm4
Copy link

hoanglm4 commented Sep 1, 2017

Dear @dariuszseweryn ,
When is 1.4.0 released ?

Thanks

@dariuszseweryn
Copy link
Owner

There are some minor things to finish. Maybe I will be able to release today. If not then early next week. Still waiting to clarify #275 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants