I am working with the core bluetooth . I have added the functionality to write/read on the characteristics . Before that I want to check whether the characteristic is writable or not . I have used the characteristic.properties for this purpose my code is :
if (characteristic.properties==CBCharacteristicPropertyRead)
{
[peripheralDevice readValueForCharacteristic:characteristic];
}
else if(characteristic.properties==CBCharacteristicPropertyWrite)
{
[peripheralDevice setNotifyValue:YES forCharacteristic:characteristic];
}
NSLog(@"the property :%d",currentCharacteristic.properties );
here is the enum for the Characteristic.properties from the documentation :
typedef NS_ENUM(NSInteger, CBCharacteristicProperties) {
CBCharacteristicPropertyBroadcast = 0x01,
CBCharacteristicPropertyRead = 0x02,
CBCharacteristicPropertyWriteWithoutResponse = 0x04,
CBCharacteristicPropertyWrite = 0x08,
CBCharacteristicPropertyNotify = 0x10,
CBCharacteristicPropertyIndicate = 0x20,
CBCharacteristicPropertyAuthenticatedSignedWrites = 0x40,
CBCharacteristicPropertyExtendedProperties = 0x80,
CBCharacteristicPropertyNotifyEncryptionRequired NS_ENUM_AVAILABLE(NA, 6_0) = 0x100,
CBCharacteristicPropertyIndicateEncryptionRequired NS_ENUM_AVAILABLE(NA, 6_0) = 0x200
};
Its working fine for the reading the value from the characteristic. But problem is while writing the value it is not going inside the second loop. I have set the characteristic with the writable property . I am getting the 136 in print statement for both of the peripheral on which I have checked . Please suggest some solution to overcome this problem ?
solved this by using ANDing operation:
if (characteristic.properties&CBCharacteristicPropertyRead!=0)
{
[peripheralDevice readValueForCharacteristic:characteristic];
}