Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 核心蓝牙设置值为';将CBT特性通知属性设置为true_Ios_Swift_Bluetooth_Cbcentralmanager_Cbperipheral - Fatal编程技术网

Ios 核心蓝牙设置值为';将CBT特性通知属性设置为true

Ios 核心蓝牙设置值为';将CBT特性通知属性设置为true,ios,swift,bluetooth,cbcentralmanager,cbperipheral,Ios,Swift,Bluetooth,Cbcentralmanager,Cbperipheral,嘿,伙计们,我正在尝试让这个蓝牙LE设备连接到应用程序并获取值。我用的是核心蓝牙,它应该能把这些值拿出来。我让它工作,但当它更新时,它突然停止通知值 func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { for characteristic in service.characteristics! { peripheral.se

嘿,伙计们,我正在尝试让这个蓝牙LE设备连接到应用程序并获取值。我用的是核心蓝牙,它应该能把这些值拿出来。我让它工作,但当它更新时,它突然停止通知值

func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
for characteristic in service.characteristics! {
  peripheral.setNotifyValue(true, for: characteristic)
  print("peripheral did discover characteristics \(characteristic)")
}
}

在委托方法调用中,我将每个CBCharacteristic对象的notify值设置为true。这意味着它更新的任何值都应该调用另一个委托方法

func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?)
但是,未调用此方法。在中,我添加了一个print语句来打印每个特征,但是当我将值设置为true时,每个特征notify属性仍然设置为NO

peripheral did discover characteristics <CBCharacteristic: 0x1700ac0c0, UUID = 28930002-C868-423A-9DC2-E9C2FCB4EBB5, properties = 0x12, value = (null), notifying = NO>
外围设备没有发现特征

我错过什么了吗?提前感谢

您可以实现
功能外围设备(uu外围设备:cbperipal,didUpdateNotificationStateFor characteristic:CBCharacteristic,error:error?)
以查看是否调用了
setNotifyValue(uu:for:)
实际上是成功的

您是否检查了特性的属性以确保支持notify?我是核心蓝牙的新手,我认为这是不可能的!我这样做了,有趣的是,除非我有这个设备的应用程序并且它是使用那个应用程序配对的,否则notify是不受支持的。现在它可以得到通知了。非常感谢你!我从你告诉我这件事中学到了很多!!!