There is no response from writeDescriptor() when used in a chain
See original GitHub issueHey. I have encountered such a problem when no response comes from method writeDescriptor
when used in a chain. Here is my code:
override fun connectDevice() {
rxBleClient.scanBleDevices(scanSettings, scanFilter)
.flatMap { scanResult -> scanResult.bleDevice.establishConnection(false) }
.flatMapSingle {
rxBleConnection = it
it.discoverServices()
}
.flatMapSingle { obtainCharacteristics(it) }
.flatMapCompletable {
readCharacteristic = it.first
writeCharacteristic = it.second
writeDescriptor(it.first)
}
.andThen(Single.fromCallable { startConnection() })
.flatMap { it }
.subscribeBy(
onSuccess = { setupAndObserveNotifications(readCharacteristic!!) },
onError = { Timber.d("$it") }
)
}
My method writeDescriptor
:
private fun writeDescriptor(readCharacteristic: BluetoothGattCharacteristic): Completable {
val descriptor = readCharacteristic.getDescriptor(READ_CHARACTERISTIC_CONFIG)
return rxBleConnection!!.writeDescriptor(descriptor, BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE)
.doOnComplete { Timber.d("Descriptor wrote.") }
.doOnError { Timber.e("Error while descriptor is writing: $it") }
}
The chain comes to writeDescriptor(it.first)
, also called doOnComplete { Timber.d("Descriptor wrote.")
, but it does not go further down the chain in andThen(Single.fromCallable { startConnection() })
and next in subscribe
. What could be the problem?
P.S. I reproduced the same example with the chain separately (without the library) withflatMapCompletable
, andThen
and etc., and everything was done correctly.
fun main() {
Single.just(1)
.delay(1, TimeUnit.SECONDS)
.flatMapCompletable { getCompletable() }
.andThen(Single.fromCallable { getSingle() })
.flatMap { it }
.subscribe { i -> println(i) }
Thread.sleep(5000)
}
private fun getCompletable(): Completable {
return Completable.fromRunnable {
Thread.sleep(1000)
}
}
private fun getSingle(): Single<Int> {
return Single.just(5)
}
In the console comes the correct answer - 5
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
There is no response from writeDescriptor() when used in a ...
Hey. I have encountered such a problem when no response comes from method writeDescriptor when used in a chain. Here is my code:...
Read more >Android BLE BluetoothGatt.writeDescriptor() return sometimes ...
Here is one reply saying that BLE is busy with writeDescriptor() and can not do other write. Here is another thread saying that...
Read more >use descriptor chain in SGDMA - Intel Communities
Hi all My current goal is to use SGDMA (ST-to-MM) to transfer video data to a memory. Later on, I'll replace the memory...
Read more >The Ultimate Guide to Android Bluetooth Low Energy
Learn about the basics of Android BLE, get an overview of important glossary terms, and real world examples to better develop Android apps....
Read more >Example Encryption Software for PC to Synergy Communication
Below is some example Python code that can be used on a PC to generate an encrypted data stream for communicating to a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
.establishConnection()
does not complete on its own. You can read about it in theObservable behaviour
part of ReadmeOk, thanks.