I am trying to write the file to the controller using RxAndroidBLE library. Currently, i am reading a file and converting int byte[] and sending it to in chuck of 244.
To perform this task i am using below flow
.flatMap(bytes -> getFileData())
.flatMapIterable(otaData -> otaData.getOtaByteArray())
.flatMapSingle(bytes -> mRxBleConnection.writeCharacteristic(OTA_DATA, bytes))
.subscribe(bytes -> {
Log.e(TAG,"Response Write "+Arrays.toString(BLEUtils.toHex(bytes)));
});
here getFileData is returning the otaData object.
the problem with this approach is all the byte array from flatMapIterable are getting flooded to mRxBleConnection.writeCharacteristic which is getting queued and then sent across to the controller. In this case controller is not able to read the data properly.
Hence i am looking for a way where once the mRxBleConnection.writeCharacteristic function finishes writing one chuck of 244 it should then only pick the next byte[] array. I am not sure how to calibrate the streams here to be sure upon writing one chuck of block and then pick the next one using RxAndroidBLE and RxJava