iOS蓝牙扫描的坑

一、后台扫描

手机作为中心模式(client):
打开后台模式中的使用蓝牙功能 TARGET→Capabilities→Background Modes→Uses Bluetooth LE accessories(勾选)

二、扫描设备方法

centralManager为蓝牙中心模块

// centralManager.scanForPeripherals(withServices: nil, options: [CBCentralManagerScanOptionAllowDuplicatesKey: true])
centralManager.scanForPeripherals(withServices: nil, options:nil)

三、ble扫描流程

从调用iOS的scan接口,到收到系统回调,这中间其实有下面几步的交互:

  1. BLE设备端发送广播ADV_

猜你喜欢

转载自blog.csdn.net/qq_25218777/article/details/131197050