I am new to the Core Bluetooth Framework. I am developing an application that acts as a peripheral. I need an application to notify the sign value to the signed centers, and also record the sign value to the connected centers. I set the value of the characteristic when it is created. The problem is that when I set the property of a characteristic for notification or recording, it shows the error "Characteristics with cached values should be read-only." Can anybody help me?
var charValue = characteristicDetail["value"] as String
var charProperties:CBCharacteristicProperties = getProperty(characteristicDetail["properties"] as String )
let data = charValue.dataUsingEncoding(NSUTF8StringEncoding)
var characteristic = CBMutableCharacteristic(type: charId, properties: charProperties, value: data, permissions: CBAttributePermissions.Readable)
func getProperty(string:String) -> CBCharacteristicProperties
{
var propertyString:CBCharacteristicProperties?
switch string{
case "r","R":
propertyString = CBCharacteristicProperties.Read
case "w","W":
propertyString = CBCharacteristicProperties.Write
case "n","N":
propertyString = CBCharacteristicProperties.Notify
case "i","I":
propertyString = CBCharacteristicProperties.Indicate
case "rw","wr","WR","RW":
propertyString = CBCharacteristicProperties.Read|CBCharacteristicProperties.Write
case "rn","nr","NR","RN":
propertyString = CBCharacteristicProperties.Read|CBCharacteristicProperties.Notify
case "wn","nw","NW","WN":
propertyString = CBCharacteristicProperties.Write|CBCharacteristicProperties.Notify
default:
propertyString = CBCharacteristicProperties.Read
}
return propertyString!
}
source
share