简体   繁体   English

BLE writeValue到外设

[英]BLE writeValue to peripheral

I am having trouble to write values to a BLE device. 我无法将值写入BLE设备。 I translated this: 我翻译了这个:

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

to Swift: 到Swift:

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

But I get the error Use of unresolved identifier 'CBCharacteristicWriteWithResponse' 但是我得到了Use of unresolved identifier 'CBCharacteristicWriteWithResponse'的错误

I am new to iOs programming and tried manyfold ways to make it work but it just wouldn't happen. 我是iOs编程的新手,并尝试了多种方法使其正常工作,但那不会发生。 Can you help me please. 你能帮我吗。

You have combined the NSLog statement and the writeValue method into some sort of bizarre mashup. 您已经将NSLog语句和writeValue方法组合成某种奇怪的混搭。

What you want is 你想要的是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM