本文介绍了连接到iBeacon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以用以下方式扫描iBeacons:

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

}
}

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

 信标1:主要:1次要:5 uuid:xxx 
Beacon 2:专业:1小调:6 uuid:xxx
Beacon 3:专业:1小调:7 uuid:xxx

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



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

解决方案

你无法获得任何直接将 CLBeacon CBPeripheral 相关联的信息。



通常,信标的GATT服务会公开一个设备名称特征,您可以向用户显示该特征,以允许他们从列表中选择要配置的设备。 / p>

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



没有通用的配置iBeacon服务定义。


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?

解决方案

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.

这篇关于连接到iBeacon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 11:23