1 BLE中心模式流程

BLE中心模式流程

  1. 建立中心管理者 cMgr
  2. 扫描外设 peripheral
  3. 扫描到设备 进行连接设备(实现一个代理方法)
    3.1 通过代理方法 didDiscoverPeripheral: 内部进行连接 ( 注意 : peripheral的名称Name)
    3.2 self.cMgr.connnectPeripheral: 方法连接外设
    3.3 如果连接成功 调代理方法 didConnectPeripheral: (表示连接成功)
  4. 扫描外设中的服务和特征
    扫描到结果后, 会触发调用代理方法 , 这个时候CBCentralMannagerDelegate已经不能满足需求, 需要新的CBPeripheralDelegate来搞定

前提是:连接外设成功

代理: peripheralDelegate 查找services

  1. services
    Tip:遍历services , 查找每个service里面的characteristics —> 2
  2. characteristics

2.1 characteristics的 值
2.2 characteristics的 Descriptor 以及 Descriptor的值 写数据 读RSSI 用通知的方式订阅数据 等
tip: 遍历 characteristics 查找每个 charactistic
Tip: 外设读取特征值

  1. 外设写数据到特征中
  2. 订阅特征的通知
    4.1 取消通知
    Tip: 外设订阅特征通知
  3. 断开连接
    5.1 停止扫描
    5.2 断开连接

你可能感兴趣的:(1 BLE中心模式流程)