CBCharacteristic-CBMutableCharacteristic学习笔记

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


CBCharacteristic学习笔记

/*!

 *  @class CBCharacteristic

 *  @discussion

 *      代表一个服务的特征

 */

@interface CBCharacteristic : NSObject


//表明这个属于哪个service

@property(weak, readonly, nonatomic) CBService *service;


//characteristic的UUID标识

@property(readonly, nonatomic) CBUUID *UUID;


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


typedef NS_OPTIONS(NSInteger, CBCharacteristicProperties) {

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

CBCharacteristicPropertyBroadcast = 0x01,

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

CBCharacteristicPropertyRead = 0x02,

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

CBCharacteristicPropertyWriteWithoutResponse = 0x04,

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

CBCharacteristicPropertyWrite = 0x08,

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

CBCharacteristicPropertyNotify = 0x10,

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

CBCharacteristicPropertyIndicate = 0x20,

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

CBCharacteristicPropertyAuthenticatedSignedWrites = 0x40,

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

CBCharacteristicPropertyExtendedProperties = 0x80,

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

CBCharacteristicPropertyNotifyEncryptionRequired NS_ENUM_AVAILABLE(NA, 6_0) = 0x100,

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

CBCharacteristicPropertyIndicateEncryptionRequired NS_ENUM_AVAILABLE(NA, 6_0) = 0x200

};


@property(readonly, nonatomic) CBCharacteristicProperties properties;


// characteristic的值

@property(retain, readonly) NSData *value;


// * *

@property(retain, readonly) NSArray *descriptors;


// 特征是否正在广播

@property(readonly) BOOL isBroadcasted;


// 特征是否正在通知

@property(readonly) BOOL isNotifying;




@interface CBMutableCharacteristic : CBCharacteristic


// 权限

typedef NS_OPTIONS(NSInteger, CBAttributePermissions) {

// 可读的

CBAttributePermissionsReadable = 0x01,

// 可写的

CBAttributePermissionsWriteable = 0x02,

// 需验证

CBAttributePermissionsReadEncryptionRequired = 0x04,

CBAttributePermissionsWriteEncryptionRequired = 0x08

}

@property(assign, readwrite, nonatomic) CBAttributePermissions permissions;


//订阅这个characteristic的central

@property(retain, readonly) NSArray *subscribedCentrals


@property(retain, readwrite, nonatomic) CBUUID *UUID;


@property(assign, readwrite, nonatomic) CBCharacteristicProperties properties;


@property(retain, readwrite) NSData *value;


@property(retain, readwrite) NSArray *descriptors;


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



你可能感兴趣的:(IOS开发,蓝牙学习笔记)