首页 > 代码库 > CBCharacteristic

CBCharacteristic

Identifying a Characteristic

@property(readonly, nonatomic) CBUUID *UUID@property(weak, readonly, nonatomic) CBService *service

 

Accessing Characteristic Data

@property(retain, readonly) NSData *value//例如体温检测服务,value为温度@property(retain, readonly) NSArray *descriptors//CBDescriptor对象数组,value外的其他值等@property(readonly, nonatomic) CBCharacteristicProperties properties//The properties of a characteristic determine how the characteristic’s value and descriptors can be used and accessed. @property(readonly) BOOL isNotifying@property(readonly) BOOL isBroadcasted//IOS8以后不使用

 

Constants

typedef enum {   CBCharacteristicPropertyBroadcast  = 0x01 ,   CBCharacteristicPropertyRead  = 0x02 ,   CBCharacteristicPropertyWriteWithoutResponse  = 0x04 ,   CBCharacteristicPropertyWrite  = 0x08 ,   CBCharacteristicPropertyNotify  = 0x10 ,   CBCharacteristicPropertyIndicate  = 0x20 ,   CBCharacteristicPropertyAuthenticatedSignedWrites  = 0x40 ,   CBCharacteristicPropertyExtendedProperties  = 0x80 ,   CBCharacteristicPropertyNotifyEncryptionRequired  = 0x100 ,   CBCharacteristicPropertyIndicateEncryptionRequired  = 0x200 ,} CBCharacteristicProperties;

Values representing the possible properties of a characteristic. Since characteristic properties can be combined, a characteristic may have multiple property values set. 

1.read,调用readValueForCharacteristic方法,然后数据更新的时候会调用peripheral:didUpdateValueForCharacteristic:error:方法。此时读取value值即可。

2.write,使用 writeValue:forCharacteristic:type:方法写数据。type值表明是否有response。(没有response的比有response的数值可以更长?)

CBCharacteristic