【问题标题】:Detect an AltBeacon with CoreBluetooth使用 CoreBluetooth 检测 AltBeacon
【发布时间】:2015-08-09 08:07:50
【问题描述】:

我想使用 CoreBluetooth 和 Swift 检测 altBeacon(由带有 QuickBeacon 应用程序的 Android 智能手机传输)。

但是当我搜索一个特定的 UUID 时,委托方法没有被调用。

   func centralManagerDidUpdateState(central: CBCentralManager!){

    if (central.state == .PoweredOff) {
        println("CoreBluetooth BLE hardware is powered off")
    }
    else if (central.state == .PoweredOn) { 
        var UUIDObj:NSArray! = [CBUUID(string: "2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")]
        self.centralManager.scanForPeripheralsWithServices(UUIDObj as [AnyObject], options: nil)
        NSLog("Scanning started"); }}

通常应该调用这个方法

func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!) {

当我将信标格式更改为“iBeacon”时,它也不起作用。 有人知道我如何使用 coreBluetooth 获得 AltBeacon 和 iBeacon 标准的广告价值吗?

更新:

当我搜索所有外围设备时,我会从我的 AltBeacon 获取此信息:

在 DidDiscoverPeripheral 中 广告数据:[kCBAdvDataIsConnectable:0] 接收信号强度指数:-47 外设名称:nil,状态:(枚举值),服务:nil,RSSI:nil,ID:<__nsconcreteuuid> A91CBF8C-DA69-B2FB-1A9A-CDDB60A48209,描述:

但是 UUID 与给定的 ID 不匹配 :(

【问题讨论】:

  • 如果您扫描外围设备而不提供特定的服务 UUID,您会发现它吗?
  • AltBeacon 似乎没有宣传其服务 UUID。因此,如果它确实广播了特定服务 UUID,则您无法对特定服务 UUID 进行 scanForPeripheral 过滤。
  • 我使用我的 Nexus 6 使用 Radius Networks 的 QuickBeacon 应用程序广播信标信号。是否有可能该应用程序或 Nexus 6 没有广播正确的包?
  • 看来是这样。由于我们可以在您的日志中读取:“Services:nil”,因此它不会广播服务。它可能有服务,但不广播它。
  • 您认为真正的 AltBeacon(例如 RadBeacon)会广播“正确”的广告数据,以便我可以通过 UUID 定义区域吗?

标签: swift ibeacon altbeacon


【解决方案1】:

我可以回答您的部分问题:CBCentralManager 的委托方法(例如 func centralManagerDidUpdateState(central: CBCentralManager!))仅在您使用队列实例化管理器时才被调用,即使用 init(delegate:queue:)init(delegate:queue:options:) 而不仅仅是init()...

【讨论】:

  • 当我没有指定服务 UUID 时,func 'centralManagerDidUpdateState' 与正常的 init 一起工作。这不是问题
猜你喜欢
  • 1970-01-01
  • 2013-01-22
  • 2023-03-21
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 1970-01-01
相关资源
最近更新 更多