iOS8 RSSI和邻近性意外结果

iOS8 RSSI和邻近性意外结果,ios,iphone,swift,core-location,ibeacon,Ios,Iphone,Swift,Core Location,Ibeacon,我正在使用CoreLocation检测教室中的4个特定信标,不幸的是,无论我如何移动以及离信标有多近,CoreLocation都为我提供了接近度:0、+/-1.00m和RSSI:0 我的控制器中的代码如下: func centralManagerDidUpdateState(central: CBCentralManager) { if(central.state == CBCentralManagerState.PoweredOn){ print("Po

我正在使用CoreLocation检测教室中的4个特定信标,不幸的是,无论我如何移动以及离信标有多近,CoreLocation都为我提供了
接近度:0、+/-1.00m
RSSI:0

我的控制器中的代码如下:

func centralManagerDidUpdateState(central: CBCentralManager) {
        if(central.state == CBCentralManagerState.PoweredOn){
            print("Powered on")
        }
        else if(central.state == CBCentralManagerState.PoweredOff){
            print("Powered off")
        }
        else if(central.state == CBCentralManagerState.Unknown){
            print("Unknown state")
        }
    }

    func centralManager(central: CBCentralManager, didConnectPeripheral peripheral: CBPeripheral) {
        print(peripheral)
    }

    func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) {
        print(advertisementData)
    }

    func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
        var knownBeacons = beacons.filter{$0.proximity != CLProximity.Unknown}
        if(knownBeacons.count > 0){
            closestBeacon = knownBeacons[0] as CLBeacon
        }

        print(beacons)

        for beacon in beacons{
            print(beacon.proximity.rawValue)
        }
    }

编辑:经过一些调试后,我发现iPhone上的iOS没有调用
didconnectperipal
didiscoverperipal
方法。

如果您正确打印了
CLBeacon
信息,一个问题可能是您拥有的信标的广告频率。如果他们以非常低的频率(每秒一次或更少)进行广播,那么iOS将很难计算出RSSI和接近度的准确值


关于您的
CBCentralManager
问题,您必须明确呼叫
scanForPeripheralsWithServices:options:
启动扫描,然后再
stopScan
。您想调用
stopScan
至少有两个原因:扫描会耗尽电池电量,几秒钟后,您将收到有关您周围的BLE外围设备所需的所有信息。您可以使用计时器或从UI手动停止扫描。收到有关外围设备的信息后,您可以对其发出connect。只有到那时,您才会收到关于
didconnectperipal
delegate方法的通知。

问题是,我的MacBook的BeaconScanner可以找到它们,与iPhone上的其他BTLE实用程序一样,所以我想我的代码中一定有错误?感谢您对
CBCentralManager
的详细介绍!您建议我寻找服务,例如serviceUUID来收集RSSI?