CBCharacteristicPropertyBroadcast 的目的

Purpose of CBCharacteristicPropertyBroadcast

配置 CBMutableCharacteristic 以将 iOS 设备设置为外围设备时,CBCharacteristicProperties 的可能值之一是 CBCharacteristicPropertyBroadcast。

但如果您选择它,在 运行 时您将获得:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'CBCharacteristicPropertyBroadcast is not allowed'

我是这样创建特征的:

let characteristic = CBMutableCharacteristic(type: myCharacteristicUUID,
                        properties: CBCharacteristicProperties.Broadcast,
                        value: characteristicValue,
                        permissions: CBAttributePermissions.Readable)

CBCharacteristicPropertyBroadcast 的目的是什么? CBCharacteristicPropertyReadCBCharacteristicPropertyNotify 有效,但我想知道为什么我不能使用其他值。

理想情况下,我希望将用户数据作为外围设备进行广播,而不是充当信标。这可行吗?

documentation 很清楚。您不能在您发布的特征上使用此 属性。此值的目的是使您能够解释从其他外设发现的特征的属性。

如果您想通知中心化您的值已更改,那么 notify 是合适的方法。