Swift-无法通过BLE读取多个特征

时间:2020-07-02 04:39:04

标签: swift bluetooth-lowenergy

我的应用程序能够通过BLE成功预订这两个特征,但它仅从特征之一读取数据。以下是我的代码,它能够成功读取单个特征,但不能成功读取多个特征。

    func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
    
    guard characteristic == rxCharacteristic,
        let data:Data = characteristic.value
        else { return }

    var myFloatArray = Array<Float>(repeating: 0, count: data.count/MemoryLayout<Float>.stride)
    myFloatArray.withUnsafeMutableBytes { data.copyBytes(to: $0) }

0 个答案:

没有答案
相关问题