连接到 iBeacon

Connect to iBeacon

我可以使用以下方式扫描 iBeacon:

func locationManager(manager: CLLocationManager!, didRangeBeacons beacons: [AnyObject]!, inRegion region: CLBeaconRegion!) {

  }
}

假设我在扫描后得到以下信标

Beacon 1: major:1 minor:5 uuid:xxx
Beacon 2: major:1 minor:6 uuid:xxx
Beacon 3: major:1 minor:7 uuid:xxx

扫描后我想连接到信标 2 并更改其特性。

我知道我可以使用 CoreBluetooth 扫描并连接到蓝牙设备并更改其特性,但问题是我如何通过 Core Bluetooth 识别哪个设备是 beacon 2?

您无法获得任何直接关联 CLBeaconCBPeripheral 的信息。

通常情况下,信标的 GATT 服务会公开一个 "device name" 特征,您可以向用户显示该特征以允许他们 select 从列表中配置要配置的设备。

正如 David 在评论中指出的那样,任何此类 GATT 服务都将是特定于供应商的,或者甚至可能不存在,信标是通过其他一些方法(例如 USB)配置的。即使提供了 GATT 服务,也可以通过配置将其禁用或仅在初始开机后的有限时间内激活。

没有定义通用 "configure an iBeacon" 服务。