Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通知有时不使用RxAndroidBle在notify/write observable中调用_Android_Bluetooth Lowenergy_Android Bluetooth_Rx Android_Rxandroidble - Fatal编程技术网

通知有时不使用RxAndroidBle在notify/write observable中调用

通知有时不使用RxAndroidBle在notify/write observable中调用,android,bluetooth-lowenergy,android-bluetooth,rx-android,rxandroidble,Android,Bluetooth Lowenergy,Android Bluetooth,Rx Android,Rxandroidble,我目前正在使用RxAndroidBle将固件写入蓝牙设备。按照它的工作方式,我必须在一个写特征标识上向蓝牙设备发送数据块(每个数据块580字节),然后在一个侦听特征标识上侦听结果,以检查蓝牙设备是否已成功确认该数据块 理想情况下,我希望这个write和notify链是一个操作,因此我使用的代码来自一个类似的堆栈溢出问题(): 最后 注意:writeData在Scheduler.io()线程中运行,我正在使用库中最新的主提交()(因为我需要新的LongWriteBuilder) 有趣的是,如果我启

我目前正在使用RxAndroidBle将固件写入蓝牙设备。按照它的工作方式,我必须在一个写特征标识上向蓝牙设备发送数据块(每个数据块580字节),然后在一个侦听特征标识上侦听结果,以检查蓝牙设备是否已成功确认该数据块

理想情况下,我希望这个write和notify链是一个操作,因此我使用的代码来自一个类似的堆栈溢出问题():

最后

注意:writeData在Scheduler.io()线程中运行,我正在使用库中最新的主提交()(因为我需要新的LongWriteBuilder)

有趣的是,如果我启动一个额外的“虚拟”可观察通知,它什么也不做:

mBleConnection
            .flatMap(rxBleConnection -> rxBleConnection.setupNotification(LISTEN_UUID))
            .flatMap(notificationObservable -> notificationObservable)
            .subscribe(Actions.empty(), Actions.empty())
上述可观察到的工作,我得到每一个通知

我怀疑我的通知设置有问题,或者我错过了某个地方的延迟。

有两件事:

  • 不保证收到通知-指示为

  • Android操作系统似乎无法反复设置通知的开关-从日志判断,
    BluetoothGattCallback.onCharacteristicChanged()
    没有被调用


潜在的解决方案是在第一个
writeData(字节[]有效载荷)
开始之前设置通知,并同时传递
\u有效载荷
可观察
,使其看起来像
writeData(字节[]有效载荷,可观察的listenCharacteristicNotifications)
。然后您可以在
LISTEN\u CHARACTERISTIC\u UUID上设置通知一次,并在每次写入时使用它。

只使用一个可观察的通知,而不是每次都设置一个新的通知,谢谢
02-23 08:46:33.765 2864-5256/com.company.android.ble I/BLE_FW_WRITE: [FW_CHUNK_24] starting
02-23 08:46:33.772 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(182789785)
02-23 08:46:33.772 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(182789785)
02-23 08:46:33.773 2864-5256/com.company.android.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 69af0004-f994-3a57-749b-0e0aad3fca18 enable: true
02-23 08:46:33.777 2864-5256/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(22527736)
02-23 08:46:33.910 2864-2888/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:33.912 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(182789785)
02-23 08:46:33.912 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(22527736)
02-23 08:46:34.055 2864-3032/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:34.059 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationCharacteristicLongWrite(71420405)
02-23 08:46:34.063 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(22527736)
02-23 08:46:34.063 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationCharacteristicLongWrite(71420405)
02-23 08:46:34.067 2864-3093/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
<more onCharacteristicWrites here, but omitted due to max post length>
02-23 08:46:34.204 2864-3032/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
02-23 08:46:34.207 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationCharacteristicLongWrite(71420405)
02-23 08:46:35.041 2864-3093/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicChanged characteristic=69af0004-f994-3a57-749b-0e0aad3fca18
02-23 08:46:35.044 2864-5256/com.company.android.ble I/BLE_FW_WRITE: [FW_CHUNK_25] starting
02-23 08:46:35.044 2864-4250/com.company.android.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 69af0004-f994-3a57-749b-0e0aad3fca18 enable: false
02-23 08:46:35.048 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(183984640)
02-23 08:46:35.049 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(183984640)
02-23 08:46:35.053 2864-5256/com.company.android.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 69af0004-f994-3a57-749b-0e0aad3fca18 enable: true
02-23 08:46:35.060 2864-5256/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(71847163)
02-23 08:46:35.185 2864-3073/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:35.188 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(183984640)
02-23 08:46:35.189 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(71847163)
02-23 08:46:35.276 2864-2887/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:35.281 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationCharacteristicLongWrite(66222734)
02-23 08:46:35.283 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(71847163)
02-23 08:46:35.283 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationCharacteristicLongWrite(66222734)
02-23 08:46:35.287 2864-3032/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
<more onCharacteristicWrites here, but omitted due to max post length>
02-23 08:46:35.441 2864-3032/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
02-23 08:46:35.447 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationCharacteristicLongWrite(66222734)
02-23 08:46:36.298 2864-2975/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicChanged characteristic=69af0004-f994-3a57-749b-0e0aad3fca18
02-23 08:46:36.301 2864-4250/com.company.android.ble I/BLE_FW_WRITE: combine data for FW_CHUNK_25
02-23 08:46:36.303 2864-4250/com.company.android.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 69af0004-f994-3a57-749b-0e0aad3fca18 enable: false
02-23 08:46:36.303 2864-5256/com.company.android.ble D/SFlashRawWrite: msg length (total): 20, payload length: 3
02-23 08:46:36.303 2864-5256/com.company.android.ble D/SFlashRawWrite: msgId: -128
02-23 08:46:36.304 2864-5256/com.company.android.ble D/SFlashRawWrite: acked msg: 17 result: 1
02-23 08:46:36.304 2864-5256/com.company.android.ble I/BLE_TIMING: chunk 25 took 1260 ms
02-23 08:46:36.304 2864-5256/com.company.android.ble I/BLE_FW_WRITE: [FW_CHUNK_26] starting
02-23 08:46:36.313 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(248228237)
02-23 08:46:36.317 2864-5256/com.company.android.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 69af0004-f994-3a57-749b-0e0aad3fca18 enable: true
02-23 08:46:36.319 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(248228237)
02-23 08:46:36.321 2864-5256/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(164719036)
02-23 08:46:36.452 2864-2888/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:36.455 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(248228237)
02-23 08:46:36.456 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(164719036)
02-23 08:46:36.602 2864-3032/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:36.616 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationCharacteristicLongWrite(227542569)
02-23 08:46:36.623 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(164719036)
02-23 08:46:36.624 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationCharacteristicLongWrite(227542569)
02-23 08:46:36.632 2864-2975/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
<more onCharacteristicWrites here, but omitted due to max post length>
02-23 08:46:36.897 2864-2975/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
02-23 08:46:36.902 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationCharacteristicLongWrite(227542569)
02-23 08:46:37.563 2864-3093/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicChanged characteristic=69af0004-f994-3a57-749b-0e0aad3fca18
02-23 08:46:37.566 2864-5256/com.company.android.ble I/BLE_FW_WRITE: [FW_CHUNK_27] starting
02-23 08:46:37.567 2864-4250/com.company.android.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 69af0004-f994-3a57-749b-0e0aad3fca18 enable: false
02-23 08:46:37.569 2864-5256/com.company.android.ble D/BluetoothGatt: setCharacteristicNotification() - uuid: 69af0004-f994-3a57-749b-0e0aad3fca18 enable: true
02-23 08:46:37.572 2864-5256/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(150502697)
02-23 08:46:37.573 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(150502697)
02-23 08:46:37.574 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(128172508)
02-23 08:46:37.711 2864-2888/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:37.715 2864-4250/com.company.android.ble D/RxBle#Radio:   QUEUED RxBleRadioOperationCharacteristicLongWrite(58981097)
02-23 08:46:37.730 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(150502697)
02-23 08:46:37.730 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(128172508)
02-23 08:46:37.871 2864-3093/com.company.android.ble D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
02-23 08:46:37.876 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(128172508)
02-23 08:46:37.879 2864-3150/com.company.android.ble D/RxBle#Radio:  STARTED RxBleRadioOperationCharacteristicLongWrite(58981097)
02-23 08:46:37.891 2864-3073/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
<more onCharacteristicWrites here, but omitted due to max post length>
02-23 08:46:38.126 2864-3073/com.company.android.ble D/RxBle#BluetoothGatt: onCharacteristicWrite characteristic=69af0003-f994-3a57-749b-0e0aad3fca18 status=0
02-23 08:46:38.128 2864-3150/com.company.android.ble D/RxBle#Radio: FINISHED RxBleRadioOperationCharacteristicLongWrite(58981097)
onCharacteristicChanged characteristic=69af0004-f994-3a57-749b-0e0aad3fca18
mBleConnection
            .flatMap(rxBleConnection -> rxBleConnection.setupNotification(LISTEN_UUID))
            .flatMap(notificationObservable -> notificationObservable)
            .subscribe(Actions.empty(), Actions.empty())