iPhone设备之间的蓝牙信号强度。

4

我有两个通过蓝牙连接的iPhone设备。是否可以获取这些设备之间的信号强度?如果可以,应该怎么做? 谢谢, K.D


1
标准蓝牙还是低功耗蓝牙?苹果实际上有一个示例应用程序展示了后者。 - Brad Larson
1个回答

8

请查看苹果蓝牙传输示例项目,了解如何通过蓝牙从一个设备传输数据到另一个设备。BTLE Apple Sample Code

您可以通过接收信号强度指示(RSSI)的值来确定信号强度。

在样例代码中,当接收到数据时,您将获得RSSI值。请检查项目中的BTLECentralViewController.m中的以下方法:

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
    // Reject any where the value is above reasonable range
    if (RSSI.integerValue > -15) {
        return;
    }

    // Reject if the signal strength is too low to be close enough (Close is around -22dB)
    if (RSSI.integerValue < -35) {
        return;
    }

    NSLog(@"Discovered %@ at %@", peripheral.name, RSSI);

    // Ok, it's in range - have we already seen it?
    if (self.discoveredPeripheral != peripheral) {

        // Save a local copy of the peripheral, so CoreBluetooth doesn't get rid of it
        self.discoveredPeripheral = peripheral;

        // And connect
        NSLog(@"Connecting to peripheral %@", peripheral);
        [self.centralManager connectPeripheral:peripheral options:nil];
    }
}

每次从其他设备接收广告数据时,您将收到一个RSSI值,通过它可以确定设备的强度和范围。
同时查看维基上的RSSI详细信息
希望这能帮到您。

如果这个答案对您有帮助,那么其他人也可以了解到这一点。它还可以帮助解决他们的问题。 - Satish Azad

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接