IOS系列——蓝牙(中心)2
来源:互联网 发布:java mvc模式是什么 编辑:程序博客网 时间:2024/06/17 01:55
CBCentralManager 与之对应的是CBPeripheraimanager
CBCentralManager对应的几种状态
typedef NS_ENUM(NSInteger, CBCentralManagerState) {// 初始的时候是未知的(刚刚创建的时候)代理CBCentralManagerStateUnknown = 0,
//正在重置状态CBCentralManagerStateResetting,//设备不支持的状态CBCentralManagerStateUnsupported,// 设备未授权状态CBCentralManagerStateUnauthorized,//设备关闭状态CBCentralManagerStatePoweredOff,// 设备开启状态 -- 可用状态CBCentralManagerStatePoweredOn,};
@property(weak, nonatomic) id<CBCentralManagerDelegate> delegate;
// 初始化方法-参数-delegate-可以放到多线程里面去创建做更多的事情-queue- (id)initWithDelegate:(id<CBCentralManagerDelegate>)delegate queue:(dispatch_queue_t)queue;//初始化方法-参数-options指定这个manager- (id)initWithDelegate:(id<CBCentralManagerDelegate>)delegate queue:(dispatch_queue_t)queue options:(NSDictionary *)options//检索外围设备通过传入一个UUID数组- (void)retrievePeripherals:(NSArray *)peripheralUUIDs //检索外围设备通过传入一个identifiers数组- (NSArray *)retrievePeripheralsWithIdentifiers:(NSArray *)identifiers// 检索已连接的外围设备- (void)retrieveConnectedPeripherals//通过服务的UUID数组返回已经连接的服务数组- (NSArray *)retrieveConnectedPeripheralsWithServices:(NSArray *)serviceUUIDs// serviceUUIDs是一个CBUUID数组,如果serviceUUIDs是nil为空的话所有的被发现的peripheral将要被返回- (void)scanForPeripheralsWithServices:(NSArray *)serviceUUIDs options:(NSDictionary *)options// 停止扫描- (void)stopScan//通过options指定的选项去连接peripheral- (void)connectPeripheral:(CBPeripheral *)peripheral options: (NSDictionary *)options//取消一个活跃的或者等待连接的peripheral的连接- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral
必须实现的方法
//仅仅在CBCentralManagerStatePoweredOn的时候可用当central的状态是OFF的时候所有与中心连接的peripheral都将无效并且都要重新连接,central的初始状态时是Unknown- (void)centralManagerDidUpdateState:(CBCentralManager *)central;
//central提供信息,dict包含了应用程序关闭是系统保存的central的信息,用dic去恢复central
//app状态的保存或者恢复,这是第一个被调用的方法当APP进入后台去完成一些蓝牙有关的工作设置,使用这个方法同步app状态通过蓝牙系统
- (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)dict
//* @param central The central manager providing this information.
* @param peripherals A list of <code>CBPeripheral</code> objects.
改方法返回一个结果当{@link retrievePeripherals} 被调用,与周边,中央能够匹配UUID
- (void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals
//peripherals表示当前连接central的所有peripherals
//这个方法返回一个结果,当retrieveConnectedPeripherals被调用是
- (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error
0 0
- IOS系列——蓝牙(中心)2
- IOS系列——蓝牙
- iOS蓝牙4.0开发例子(中心设备)
- (一)CoreBluetooth iOS 蓝牙 “中心模式”
- IOS学习笔记—IOS通知中心 .
- iOS蓝牙——test
- iOS 蓝牙使用小结 bluetooth中心模式swift,oc
- iOS蓝牙开发(二):iOS 蓝牙4.0中心模式 代码实现
- iOS蓝牙开发 Bluetooth蓝牙CoreBluetooth 蓝牙中心设备的实现 蓝牙外设的实现 有Demo
- iOS蓝牙开发 Bluetooth蓝牙CoreBluetooth 蓝牙中心设备的实现 蓝牙外设的实现 有Demo
- iOS监听模式系列之通知中心
- ios开发——NSNotificationCenter (通知中心)
- IOS学习之——通知中心
- iOS 购物—个人中心界面
- 蓝牙中心开发
- IOS学习笔记11—IOS通知中心
- 淘淘商城系列——dubbo监控中心
- IOS开发之——IOS模拟器调试蓝牙BLE
- poj1961-kmp的next数组的简单应用(2)
- Android开发之如何获取wifi的名称即SSID
- 2014微软编程之美初赛第一场第三题 活动中心
- 设计模式之适配器模式(Adapter)
- 01-12:RadioGroup、RadioButton、CheckBox、Toast的用法
- IOS系列——蓝牙(中心)2
- 研究 UIActivityViewController
- Floyd算法
- java右下角弹窗效果
- 【20140422】paxos的一次总结
- eclipse 切换svn账号
- mysql大小写问题
- hive HQL笔记
- java.util.concurrent介绍