Search code examples
iosiphoneswiftbluetooth-lowenergycore-bluetooth

How to initialize CBMutableCharacteristic with multiple properties in iOS swift


While initializing CBMutableCharacteristic how can we add multiple properties and permissions to it.

let customChara = CBMutableCharacteristic(type: Constants.RX_UUID, properties: , value: data, permissions: )

I would like to add read & notify as properties, but above function allows only to add one property. Same in the case of Permission.

I already came across an older solution but it's not working now.How to initialize a CBMutableCharacteristic with multiple CBCharacteristicProperties and Permissions


Solution

  • You simply need to pass an Array of CBCharacterProperties to the function's properties argument.

    let customChara = CBMutableCharacteristic(type: Constants.RX_UUID, properties: [.authenticatedSignedWrites,.broadcast], value: data, permissions: .writeable)