- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 BLE 基金可以将数据写入外围服务:
func writeData(data: [Int8]) {
let character = CBMutableCharacteristic(type: cuivienenCharacterUUID, properties: [.Write, .Read, .Notify], value: nil, permissions: [.Readable, .Writeable])
test_peripheral.writeValue(NSData(bytes: data, length: data.count), forCharacteristic: character, type: .WithResponse)
test_peripheral.setNotifyValue(true, forCharacteristic: character)
}
我已经初始化了 test_peripheral 并将其委托(delegate)设置为 self。但是test_peripheral.writeValue
从未打过电话func peripheral(peripheral: CBPeripheral, didWriteValueForCharacteristic characteristic: CBCharacteristic, error: NSError?)
。我连错误消息都收不到!
test_peripheral.setNotifyValue
也是如此。它从不调用func peripheral(peripheral: CBPeripheral, didUpdateNotificationStateForCharacteristic characteristic: CBCharacteristic, error: NSError?)
我的代码有什么问题吗?
最佳答案
CB特性
test_peripheral.writeValue(NSData(bytes: data, length: data.count), forCharacteristic: character, type: .WithResponse)
不应由您自己的代码初始化。您应该在
中找到您的 CBCharacteristicfunc peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?)
然后使用它。
关于ios - CBPeripheral setNotifyValue WithResponse 不调用 didWriteValueForCharacteristic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34336949/
我正在尝试使用 Core Bluetooth 连接两部 iPhone。一个运行外围设备,另一个运行中央设备。看来这两个设备已连接。并且在典型的控制流中调用每个方法,直到 peripheralManag
我想在值更改时收到通知。我正在关注本教程-> Introduction to Core Bluetooth: Building a Heart Rate Monitor 我使用此蓝牙设备-> IC c
我有一个 BLE 基金可以将数据写入外围服务: func writeData(data: [Int8]) { let character = CBMutableCharacteristic(t
大家好,我正在尝试让这个蓝牙 LE 设备连接到应用程序并获取值。我正在使用 Core Bluetooth,它应该可以获取值。我让它工作,但突然间它在更新时停止通知值。 func peripheral(
我正在开发一个需要与外部设备建立蓝牙连接的应用程序,并且我成功地与外部设备建立了连接。 现在,下面的 CBPeripheralManager 委托(delegate)在 iOS 10 中生成错误并在
我是一名优秀的程序员,十分优秀!