BLE writeValue到外设

时间:2014-10-13 10:13:50

标签: ios swift bluetooth-lowenergy

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

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

到斯威夫特:

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

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

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

1 个答案:

答案 0 :(得分:1)

您已将NSLog语句和writeValue方法合并为某种奇怪的混搭。

你想要的是

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