CoreBluetooth使用 (客户端外部设备)
来源:互联网 发布:wkwebview 加载本地js 编辑:程序博客网 时间:2024/05/19 21:40
自己写了一个Demo 下载地址:http://download.csdn.net/detail/i_k_o_x_s/9031359
CBPeripheralManager类
//初始化的时候 调用代理方法 返回当前设备的蓝牙状态
-(void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral
当peripheral.state 为 CBPeripheralManagerStatePoweredOn 时候蓝牙设备是打开的
//给当前设备添加服务
- (void)addService:(CBMutableService *)service;
//添加服务后执行代理方法
-(void)peripheralManager:(CBPeripheralManager *)peripheral didAddService:(CBService *)service error:(NSError *)error
//开启广播 让外部蓝牙设备能够搜索到本机设备
关闭广播
advertisementData:添加广告发出去的信息
- (void)startAdvertising:(NSDictionary *)advertisementData;
- (void)stopAdvertising;
//开广播后执行代理方法
-(void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(NSError *)error
//外部设备连接到当前设备 回调代理方法
central与当前设备连接的外部设备 characteristic外部设备所订阅的特征
-(void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic{
//外部设备与当前设备断开连接 回调代理方法
central与当前设备连接的外部设备 characteristic外部设备所订阅的特征
-(void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic{
//更新某一个特征,其他外部设备订阅了这个特征 会收到对应value数据
- (BOOL)updateValue:(NSData *)value forCharacteristic:(CBMutableCharacteristic *)characteristic onSubscribedCentrals:(NSArray *)centrals;
// 外部设备的CBPeripheral的代理方法 回调
-(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
//接受到外部设备发送来的消息 回调代理方法
request 返回多个CBATTRequest 这个类
-(void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray *)requests{
@property(readonly, retain, nonatomic) CBCentral *central; //发送过来的中心设备
@property(readonly, retain, nonatomic) CBCharacteristic *characteristic;//特征
@property(readonly, nonatomic) NSUInteger offset;
@property(readwrite, copy) NSData *value;//数据
CBMutableService类
//设定特定的CBUUID
- (instancetype)initWithType:(CBUUID *)UUID primary:(BOOL)isPrimary
//一个服务可以添加多个特征
@property(retain,readwrite)NSArray *characteristics;
CBMutableCharacteristic类
//初始化特征的时候 特定特征的UUID 对应的性能:
(根据具体需求)CBCharacteristicPropertyNotify和CBCharacteristicPropertyWrite //通知:可写
- (instancetype)initWithType:(CBUUID *)UUID properties:(CBCharacteristicProperties)properties value:(NSData *)value permissions:(CBAttributePermissions)permissions
- CoreBluetooth使用 (客户端外部设备)
- CoreBluetooth使用 (服务端中心设备)
- 蓝牙 CoreBluetooth基本使用
- CoreBluetooth.framework基本使用
- CoreBluetooth框架(转)
- coreBlueTooth(续)
- CoreBluetooth
- CoreBluetooth
- CoreBluetooth
- CoreBluetooth
- CoreBluetooth的使用问题汇总
- ios蓝牙框架CoreBluetooth使用
- iOS 使用蓝牙技术MultipeerConnectivity、CoreBluetooth
- iOS CoreBluetooth 的使用讲解
- SPOOLing (即外部设备联机并行操作),
- IOS开发-使用蓝牙(CoreBluetooth.f…
- 使用WCF构建沙箱模型虚拟外部设备
- iOS CoreBluetooth的swift实现 (1)
- C++ Builder xe8 安卓开发之使用Memo保存数据的方法
- Vim简明教程【CoolShell】
- zookeeper-3.4.6格式化问题 hdfs zkfc -formatZk报错
- oc NSdictionary / NSSet / NSCountedSet / 快速遍历 / NSEnumerator
- DOM(二)-05-(示例-展开闭合列表3)
- CoreBluetooth使用 (客户端外部设备)
- 获取页面离开onbeforeunload与onunload事件的返回值
- UIViewController中的edgesForExtendedLayout和extendedLayoutIncludesOpaqueBars属性
- java awt根据字符串的信息和字体获取所占有的像素
- nginx配置
- 视图中order by 的使用
- 《AndroidStudio每日一贴》3.快速切换代码风格、配色方案和键盘
- DOM(二)-06-(示例-好友菜单)
- oracle优化的相关文章链接