我无法将值写入BLE设备。我翻译了这个:

NSLog(@"Writing value for characteristic %@", interestingCharacteristic);
    [peripheral writeValue:dataToWrite forCharacteristic:interestingCharacteristic
        type:CBCharacteristicWriteWithResponse];


到Swift:

peripheral.writeValue("Writing value for characteristic", forCharacteristic: interestingCharacteristic, type: CBCharacteristicWriteWithResponse)


但我收到错误Use of unresolved identifier 'CBCharacteristicWriteWithResponse'

我是iOs编程的新手,并尝试了多种方法使其正常工作,但那不会发生。你能帮我吗。

最佳答案

您已经将NSLog语句和writeValue方法组合成某种奇怪的混搭。

你想要的是

println("Writing value for characteristic \(interestingCharacteristic)")
peripheral.writeValue(dataToWrite, forCharacteristic:interestingCharacteristic, type: CBCharacteristicWriteType.WithResponse)

关于ios - BLE writeValue到外设,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26337560/

10-09 13:02