如何使用RxSwift将2D字节数组写入蓝牙特性?

时间:2018-07-05 11:50:59

标签: ios arrays swift rx-swift rxbluetooth

我正在尝试将二维字节数组写入外围设备的主要特征。我正在使用RxSwiftRxBluetoothKit

我正在通过制作20个字节的块来做大字节数组的fragmentation,现在我想一一发送这些块。

我有2D字节数组作为[[1,2,3,4,5],[6,7,8,9],[10,11,12]] 我想一次将一个数组写入具有响应的特征中。收到响应后,我想编写下一个Array,直到流完成。

我正在尝试以下...

    func send2DByteArray(byte: largeByteArray) -> Observable<CharacteristicProtocol> {

    let smallChunksArray: [[UInt8]] = makeChunks(of data: byte) // I get 2D array with chunks

        smallChunksArray.forEach ({ chunk in
        // here i want to write into characteristic with response
        // and repeat this until all chunks are sent
        })
}

我该如何解决?还是有其他方法可以解决?

0 个答案:

没有答案
相关问题