我使用以下代码来监听来自我的Bluetooth LE设备的不请自来的消息。例如,我期望一个字节数组,上面写着“ datc00099”。而是,映射器返回空的SingleSource。这里可能出什么问题了?
val charUUID = scanResult.scanRecord.serviceUuids?.get(0)?.uuid
/* Establish connection to device */
rxBleDevice!!.establishConnection(false) ?
.doOnNext {
_ ->
Log.d("Device: ", "Connection Established")
} ?
.flatMapSingle {
rxBleConnection ->
charUUID ? .let {
rxBleConnection.readCharacteristic(it)
}
} ? .subscribe({
count ->
// count should be in bytes
println("OUTPUT: $count")
}, {
throwable ->
Log.d("ERROR: ", "$throwable")
})
错误:
D/ERROR:: java.lang.NullPointerException: The mapper returned a null SingleSource
调试: