首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏哈雷彗星撞地球

    iOS CoreBluetooth 的使用讲解概念分析代码实战

    概念 CBPeripheral 蓝牙外设,比如蓝牙手环、蓝牙心跳监视器、蓝牙打印机。 而实际的数据是从蓝牙外设(CBPeripheral),也就是蓝牙手环等这类设备中获取,所以CBPeripheral就相当于是服务器,与他们有些不同的是,蓝牙数据传输是服务器(CBPeripheral)一直在广播发送数据 它可以既广播发送数据,又获取其他设备的数据,但是它只能扮演一种角色,如果iOS 设备A 通过蓝牙主动连接了 设备B,那么设备A是CBCentral,设备B是CBPeripheral;但是如果是设备B连接了设备 A,那么设备B就是CBCentral,设备A是CBPeripheral。 YES]; } 连接某个外设成功后,查找其具有的服务 - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral

    2.4K30发布于 2018-08-22
  • 来自专栏学海无涯

    iOS开发之BLE(二)——外设连接与断开

    CoreBluetooth,初始化中心管理者CBCentralManager并设置CBCentralManagerDelegate 监听CBCentralManager的状态,当是On的时候进行外设搜索 发现外设CBPeripheral // 外设 var peripheral: CBPeripheral? // 外设数组 var peripherals: [CBPeripheral]! / 连接外设的结果 // 1 连接成功 func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral // 2 连接失败 func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral // 3 丢失连接 func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral

    3.5K20发布于 2019-03-22
  • 来自专栏一“技”之长

    iOS开发之蓝牙通讯 原

    *)retrievePeripheralsWithIdentifiers:(NSArray<NSUUID *> *)identifiers; //根据服务id获取所有连接的设备 - (NSArray<CBPeripheral peripheral; //连接外设失败 - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral NSError *)error; //断开外设连接 - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager *)peripheral; 四、中心设备与外设对象CBCentral与CBPeripheral  *)peripheral didDiscoverServices:(nullable NSError *)error; //在服务中发现子服务回调的方法 - (void)peripheral:(CBPeripheral

    1.4K20发布于 2018-08-15
  • 来自专栏学海无涯

    iOS开发之蓝牙(一)

    corebluetooth 重要的类与协议 CBCentral:中心设备,发起连接的是CBCentral CBCentralManager:中心设备管理者,类似定位中的CLLocationManager CBPeripheral :外围设备,被连接的设备是CBPeripheral CBService:外围设备的服务,每个外围设备都会提供很多服务 CBCharacteristic:外围设备的特征,包含在每个服务里 CBDescriptor CBCharacteristic的信息或属性 CBCentralManagerDelegate:CBCentralManager对象遵守的协议,用于监视外围设备的发现、连接和检索 CBPeripheralDelegate:CBPeripheral

    1.5K41发布于 2019-03-15
  • 来自专栏网罗开发

    iOS 蓝牙4.0开发使用(内附 Demo)

    @property (nonatomic, strong) NSMutableArray *peripherals; // 扫描到的设备 @property (nonatomic, strong) CBPeripheral *cbPeripheral; // 外设状态 @property (nonatomic, assign) CBManagerState peripheralState; @end // 蓝牙4.0设备名 广告信息 @param RSSI 信号强度 */ - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral param error 错误信息 */ - (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral @param error 错误信息 */ - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral

    2.1K10发布于 2021-01-29
  • 来自专栏网罗开发

    实战分享:Swift 蓝牙打印机数据排版

    接收搜索到打印机的回调 extension ViewController: BaseManagerDelegate { func discoverPeripheral(_ peripheral: CBPeripheral var currentPeripheral: CBPeripheral? var writeCharacteristic: CBCharacteristic! // 2 public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral () } func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral 蓝牙外围设备代理方法 extension BaseManager: CBPeripheralDelegate { //发现服务 func peripheral(_ peripheral: CBPeripheral

    1.6K10发布于 2021-09-29
  • 来自专栏iOS 备忘录

    一文学会iOS蓝牙开发

    central { } // 扫描到设备 - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral } } } } // 连接成功 - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral } } } // 发现特征的回调, 发现characteristics,由发现服务调用(上一步),获取读和写的characteristics - (void)peripheral:(CBPeripheral 看是否需要执行特定指令,用于判断是否连接成功 [self makeConnectWrite]; } } } //读数据的回调 - (void)peripheral:(CBPeripheral ; // 根据文档,对于数据进行解密或者其他处理,然后通过指定的判断逻辑,判断是否指令是否执行成功 } } //是否写入成功的回调 - (void)peripheral:(CBPeripheral

    3.6K20编辑于 2023-12-27
  • 来自专栏一“技”之长

    iOS简易蓝牙对战五子棋游戏设计思路之一——核心蓝牙通讯类的设计

        UIView * _searchGameView;     //设备中心管理对象     CBCentralManager * _centerManger;     //要连接的外设     CBPeripheral @YES}];     } } //连接外设成功的回调 -(void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral  options:@{CBConnectPeripheralOptionNotifyOnConnectionKey:@YES}]; } //发现服务后回调的方法 -(void)peripheral:(CBPeripheral forService:service];             break;         }              } } //开发服务中的特征值后回调的方法 -(void)peripheral:(CBPeripheral             _centerWriteChara = characteristic;         }     } } //所监听的特征值更新时回调的方法 - (void)peripheral:(CBPeripheral

    1.5K60发布于 2018-08-15
  • 来自专栏搜狗测试

    APP与硬件交互-蓝牙连接测试

    property (nonatomic, strong) CBCentralManager*centralManager; //中心管理者 @property (nonatomic, strong) CBPeripheral 就会自动回调下面的协议方法 /** 发现符合要求的外设,回调 */ - (void)centralManager:(CBCentralManager*)central didDiscoverPeripheral:(CBPeripheral 如果连接成功就会回调这个协议方法 /** 连接成功 */­­­ - (void)centralManager:(CBCentralManager*)central didConnectPeripheral:(CBPeripheral 外设连接失败 /** 连接失败的回调 */ - (void)centralManager:(CBCentralManager*)central didFailToConnectPeripheral:(CBPeripheral //丢失连接 掉线 /** 断开连接 */ - (void)centralManager:(CBCentralManager*)central didDisconnectPeripheral:(CBPeripheral

    6.3K11发布于 2019-07-30
  • 来自专栏哈雷彗星撞地球

    iOS Bluetooth 打印小票(二)

    scanForPeripheralsWithServiceUUIDs:nil options:nil didDiscoverPeripheral:^(CBCentralManager *central, CBPeripheral scanForPeripheralsWithServiceUUIDs:nil options:nil didDiscoverPeripheral:^(CBCentralManager *central, CBPeripheral 这里给出了三种方式,前两种方式都需要先设置好搜索到蓝牙外设之后的回调, 即: manager.discoverPeripheralBlcok = ^(CBCentralManager *central, CBPeripheral self.deviceArray.count; i++) { NSDictionary *dict = [self.deviceArray objectAtIndex:i]; CBPeripheral servicesOptions:nil characteristicsOptions:nil completeBlock:^(HLOptionStage stage, CBPeripheral

    3.7K20发布于 2018-08-22
  • 来自专栏JusterZhu

    MASA MAUI Plugin IOS蓝牙低功耗(三)蓝牙扫描

    eventWaitHandle.WaitOne(); } public override void DiscoveredPeripheral(CBCentralManager central, CBPeripheral private BluetoothDevice(CBPeripheral peripheral) { _peripheral = peripheral; } public static implicit operator BluetoothDevice(CBPeripheral peripheral) { null : new BluetoothDevice(peripheral); } public static implicit operator CBPeripheral

    2.4K10编辑于 2022-12-07
  • 来自专栏蓝牙技术

    蓝牙开发笔记

    //把数据写到Characteristic中//写数据-(void)writeCharacteristic:(CBPeripheral *)peripheral characteristic

    40810编辑于 2023-09-27
  • 来自专栏Antony iOS Development

    iOS蓝牙开发如何更好地收发数据

    Swift版)如下: // 第7、8步: // 发现特征的回调(委托)方法(假设在这之前已经「成功连接」、「发现服务」) func peripheral(peripheral: CBPeripheral } } // 第9步: // 最终,蓝牙发过来的数据,我们会在这个回调方法中拿到 func peripheral(peripheral: CBPeripheral // 也就是上面的第8、9两步合在一个方法中了 [_baby notify:peripheral characteristic:_dataOutCharacteristic block:^(CBPeripheral

    3.4K32发布于 2019-02-14
  • 来自专栏Antony iOS Development

    iOS中的「回调(callback)」

    手机每成功连接一个设备(某事件被触发),这个方法都会被调用(回调) - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral } // 成功连接一个蓝牙设备的回调(官方框架) - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral MyCnetralManager.m文件 // 成功连接一个蓝牙设备的回调(官方框架) - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral MyCnetralManager.m文件 // 成功连接一个蓝牙设备的回调(官方框架) - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral

    4.5K30发布于 2019-02-14
  • 来自专栏iOS Developer

    Github源码推荐:(01.04):iOS开发蓝牙,启动动画,自定义Tabbar

    babyDelegate{ //设置扫描到设备的委托 [baby setBlockOnDiscoverToPeripherals:^(CBCentralManager *central, CBPeripheral

    82420发布于 2018-07-06
  • 来自专栏APP开发

    手机APP与蓝牙通讯的开发框架

    特点:提供CBCentralManager和CBPeripheral类,用于设备管理和数据传输。支持多设备连接和数据更新通知。需要处理异步回调,开发复杂度较高9。

    1.1K10编辑于 2025-03-06
  • 来自专栏iOS逆向与安全

    iOS小技能: static、extern 存储类的应用(创建共享实例、申明公共方法、全局字符串常量)

    (assign, nonatomic) BOOL IsreqGetCurrentSysUsering; /** 蓝牙打印机的连接信息 */ @property(nonatomic,strong)CBPeripheral

    1.2K30编辑于 2022-08-22
领券