CBCharacteristic-CBMutableCharacteristic学习笔记

如有不对的地方欢迎留言指正。谢谢


CBCharacteristic学习笔记

/*!

 *  @class CBCharacteristic

 *  @discussion

 *      代表一个服务的特征

 */

@interface CBCharacteristic : NSObject


//表明这个属于哪个service

@property(weakreadonlynonatomicCBService *service;


//characteristic的UUID标识

@property(readonlynonatomicCBUUID *UUID;


// characteristic的属性,是一个结构体


typedef NS_OPTIONS(NSInteger, CBCharacteristicProperties) {

// 标识这个characteristic的属性是广播

CBCharacteristicPropertyBroadcast0x01,

// 标识这个characteristic的属性是读

CBCharacteristicPropertyRead0x02,

// 标识这个characteristic的属性是写-没有响应

CBCharacteristicPropertyWriteWithoutResponse0x04,

// 标识这个characteristic的属性是写

CBCharacteristicPropertyWrite0x08,

// 标识这个characteristic的属性是通知

CBCharacteristicPropertyNotify0x10,

// 标识这个characteristic的属性是声明

CBCharacteristicPropertyIndicate0x20,

// 标识这个characteristic的属性是通过验证的

CBCharacteristicPropertyAuthenticatedSignedWrites0x40,

// 标识这个characteristic的属性是拓展

CBCharacteristicPropertyExtendedProperties0x80,

// 标识这个characteristic的属性是需要加密的通知

CBCharacteristicPropertyNotifyEncryptionRequiredNS_ENUM_AVAILABLE(NA, 6_0)0x100,

// 标识这个characteristic的属性是需要加密的申明

CBCharacteristicPropertyIndicateEncryptionRequiredNS_ENUM_AVAILABLE(NA, 6_0)0x200

};


@property(readonlynonatomicCBCharacteristicPropertiesproperties;


// characteristic的值

@property(retainreadonlyNSData *value;


// * *

@property(retainreadonlyNSArray *descriptors;


// 特征是否正在广播

@property(readonlyBOOL isBroadcasted;


// 特征是否正在通知

@property(readonlyBOOL isNotifying;




@interface CBMutableCharacteristic : CBCharacteristic


// 权限

typedef NS_OPTIONS(NSInteger, CBAttributePermissions) {

// 可读的

CBAttributePermissionsReadable0x01,

// 可写的

CBAttributePermissionsWriteable0x02,

// 需验证

CBAttributePermissionsReadEncryptionRequired0x04,

CBAttributePermissionsWriteEncryptionRequired0x08

}

@property(assignreadwritenonatomicCBAttributePermissionspermissions;


//订阅这个characteristic的central

@property(retainreadonlyNSArray *subscribedCentrals


@property(retainreadwritenonatomicCBUUID *UUID;


@property(assignreadwritenonatomic)CBCharacteristicProperties properties;


@property(retainreadwriteNSData *value;


@property(retainreadwriteNSArray *descriptors;


- (id)initWithType:(CBUUID *)UUID properties:(CBCharacteristicProperties)properties value:(NSData *)value permissions:(CBAttributePermissions)permissions;

你可能感兴趣的:(CBCharacteristic-CBMutableCharacteristic学习笔记)