我正在对 BLE 进行长时间写入以进行 OTA 更新,但我需要等待 BLE 设备的写入响应以发送更多数据,但我不知道如何捕获设备写入响应,我是使用带有 android 7 的三星 Galaxy Tab s2 和 Kotlin 作为我的代码
override fun otaDataWrite(data:ByteArray) {
manager.connection?.flatMap { rxBleConnection: RxBleConnection? -> rxBleConnection?.createNewLongWriteBuilder()
?.setCharacteristicUuid(OTACharacteristics.OTA_DATA.uuid)
?.setBytes(data)
?.setMaxBatchSize(totalPackages)
?.build()
}?.subscribe({ t: ByteArray? ->
Log.i("arrive", "data ${converter.bytesToHex(t)}")
manageOtaWrite()
}, { t: Throwable? -> t?.printStackTrace() })
每次我编写特征时,订阅都会立即用写入的数据响应我,我需要捕获特征的响应,以发送更多数据