Connect to iBeacon

2019-02-26 15:27发布

I can scan for iBeacons with:

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

  }
}

let suppose I get the following beacons after scanning

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

After the scan I want to connect to beacon 2 and change its characteristics.

I know I can use CoreBluetooth to scan and connect to a Bluetooth device and change its characteristics, but the problem is how can I identify which device is beacon 2 via Core Bluetooth?

1条回答
孤傲高冷的网名
2楼-- · 2019-02-26 16:00

You cannot obtain any information that directly relates a CLBeacon to a CBPeripheral.

Typically the beacon's GATT service will expose a "device name" characteristic that you can display to the user to allow them to select the device to be configured from a list.

As David pointed in the comments, any such GATT service will be vendor specific, or it may not even exist, with the beacon being configured through some other method, such as USB. Even where a GATT service is provided it may be disabled through configuration or only active for a limited period after initial power-on.

There is no generic "configure an iBeacon" service defined.

查看更多
登录 后发表回答