CBCentralManager

Initializing a Central Manager

- (instancetype)initWithDelegate:(id<CBCentralManagerDelegate>)delegate queue:(dispatch_queue_t)queue//建立Center
- (instancetype)initWithDelegate:(id<CBCentralManagerDelegate>)delegate queue:(dispatch_queue_t)queue options:(NSDictionary *)options

 

Establishing or Canceling Connections with Peripherals

- (void)connectPeripheral:(CBPeripheral *)peripheral options:(NSDictionary *)options//启动连接某设备
- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral//断开连接

 

Retrieving Lists of Peripherals

- (void)retrieveConnectedPeripherals//获取已经连接的设备。回调centralManager:didRetrieveConnectedPeripherals。如果与其他Center连接也会获得。
- (NSArray *)retrieveConnectedPeripheralsWithServices:(NSArray *)serviceUUIDs//直接返回peripherals列表,无需回调。IOS7新增以取代上个方法。
- (void)retrievePeripherals:(NSArray *)peripheralUUIDs//根据UUID获得设备。回调centralManager:didRetrievePeripherals。
- (NSArray *)retrievePeripheralsWithIdentifiers:(NSArray *)identifiers//直接返回peripherals列表。 

 

Scanning or Stopping Scans of Peripherals

- (void)scanForPeripheralsWithServices:(NSArray *)serviceUUIDs options:(NSDictionary *)options//启动扫描。回调diddiscover
- (void)stopScan//停止扫描

 

Monitoring Properties

@property(readonly) CBCentralManagerState state//状态。系统调用centralManagerDidUpdateState更新状态。主要为当前蓝牙状态。
@property(weak, nonatomic) id< CBCentralManagerDelegate > delegate

 

Constants

  

Central Manager Initialization Options

NSString *const  CBCentralManagerOptionShowPowerAlertKey ;
NSString *const  CBCentralManagerOptionRestoreIdentifierKey;

  

Peripheral Scanning Options

NSString *const  CBCentralManagerScanOptionAllowDuplicatesKey ;
NSString *const  CBCentralManagerScanOptionSolicitedServiceUUIDsKey;

 


Peripheral Connection Options

NSString *const  CBConnectPeripheralOptionNotifyOnConnectionKey ;
NSString *const  CBConnectPeripheralOptionNotifyOnDisconnectionKey ;
NSString *const  CBConnectPeripheralOptionNotifyOnNotificationKey;

 

Central Manager State

typedef enum {
   CBCentralManagerStateUnknown  = 0,//未知状态,为初始状态,会马上更新。
   CBCentralManagerStateResetting ,//连接丢失,正在重启,会马上更新
   CBCentralManagerStateUnsupported ,//不支持低功耗蓝牙
   CBCentralManagerStateUnauthorized ,//不允许此APP使用低功耗蓝牙
   CBCentralManagerStatePoweredOff ,//蓝牙关闭
   CBCentralManagerStatePoweredOn ,//蓝牙打开并可以正常使用
} CBCentralManagerState;

 

posted on 2014-09-19 10:50  嘉遁  阅读(752)  评论(0编辑  收藏  举报

导航