Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to read an unsolicited data stream from my Bluetooth device. The data should appear as a byte array. Unfortunately, the UUID I'm supplying doesn't seem to be the correct one. What could be going wrong?

val stringDeviceUUID = rxBleDevice.bluetoothDevice.uuids[0].toString()
val charUUID = UUID.fromString(stringDeviceUUID)

println("$stringDeviceUUID = $charUUID?")

/* If device if it is not already connected... */
if (rxBleDevice.connectionState != RxBleConnection.RxBleConnectionState.CONNECTED) {

 /* Establish connection to device */
 device !!.establishConnection(false) ?
  .doOnNext {
   _ -> Log.d("Device: ", "Connection Established")
  } ?
  .flatMapSingle {
   rxBleConnection -> rxBleConnection.readCharacteristic(charUUID)
  } ? .subscribe({
   count ->
   // count should be in bytes
   println("OUTPUT: $count")

  }, {
   throwable ->
   Log.d("Device: ", "$throwable")
  })


}

I get the following error:

D/Device:: com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException: Characteristic not found with UUID 00001101-0000-1000-8000-00805f9b34fb

What is wrong with this UUID? This is precisely the UUID I retrieve from the device so why won't it let me communicate?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
355 views
Welcome To Ask or Share your Answers For Others

1 Answer

It can't be seen from your code snippet, but are rxBleDevice and device the same RxAndroidBle instance? If not, perhaps replace device !!.establishConnection(false) with rxBleDevice.establishConnection(false)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...