com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException: Characteristic not found with UUID

ⅰ亾dé卋堺 提交于 2020-01-06 08:29:20

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/55386104/com-polidea-rxandroidble2-exceptions-blecharacteristicnotfoundexception-charact

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!