1

I use the following code to listen for an unsolicited message from my Bluetooth LE device. I am expecting a byte array with text that says "datc00099", for example. Instead, the mapper is returning a null SingleSource. What could be going wrong here?

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")
 })

Error:

D/ERROR:: java.lang.NullPointerException: The mapper returned a null SingleSource

Debug:

enter image description here

Martin Erlic
  • 5,467
  • 22
  • 81
  • 153

0 Answers0