1

In my application I'm using RxAndroidBLE library. Thanks for the awesome library. But I have some issues. I'm trying to connect to BLE device using

rxBleDevice.establishConnection(false)

Device is out of range. Timeout for connect operation is 30 seconds. At the same time I want to discover other devices using

rxBleClient.scanBleDevices(scanSettings)

But scan operation getting queued and will be performed after connect operation timeout (30 seconds). I can see this behavior in the logs:

08-01 17:25:59.978 : QUEUED   ConnectOperation(155884145)
08-01 17:25:59.981 : STARTED  ConnectOperation(155884145)
08-01 17:25:59.989 : Connecting without reflection
08-01 17:26:15.585 : QUEUED   ScanOperationApi21(75017989)
08-01 17:26:18.353 : onConnectionStateChange newState=0 status=133
08-01 17:26:18.361 : Connection operations queue to be terminated (C3:27:5F:B2:60:C9)
08-01 17:26:18.363 : Terminated.
08-01 17:26:18.370 : FINISHED ConnectOperation(155884145) in 18385 ms
08-01 17:26:18.377 : STARTED  ScanOperationApi21(75017989)
08-01 17:26:18.379 : Scan operation is requested to start.
08-01 17:26:18.381 : QUEUED   DisconnectOperation(41108292)
08-01 17:26:18.398 : FINISHED ScanOperationApi21(75017989) in 26 ms
08-01 17:26:18.401 : STARTED  DisconnectOperation(41108292)
08-01 17:26:18.410 : FINISHED DisconnectOperation(41108292) in 10 ms

Is this correct and expected behavior? And can I somehow start scan operation immediately without queueing?

Dariusz Seweryn
  • 3,212
  • 2
  • 14
  • 21
Kulibin
  • 444
  • 4
  • 12

1 Answers1

1

Is this correct and expected behavior?

Yes, this is the expected behaviour. Some BLE stack implementations did not handled well a simultaneous scan and connection which can result in status=133. It is still advised to not to do it.

And can I somehow start scan operation immediately without queueing?

While using the RxAndroidBle every scan operation is being queued on the main client queue. While having in mind the above warning you may try to use connection with autoConnect=true which will not block the main client queue for long.

Alternatively you can use vanilla Android API to perform the scan.

Dariusz Seweryn
  • 3,212
  • 2
  • 14
  • 21