RxAndroidBLE:映射器返回空的SingleSource

时间:2019-03-27 21:38:11

标签: android bluetooth-lowenergy rx-java2 rxandroidble rxbluetooth

我使用以下代码来监听来自我的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

调试:

enter image description here

0 个答案:

没有答案