【问题标题】:Bluetooth signal strength between iphone devicesiPhone设备之间的蓝牙信号强度
【发布时间】:2014-08-12 16:46:04
【问题描述】:

我有两个通过蓝牙连接的 iphone 设备。是否有可能在这些设备之间获得信号强度?如果可能的话,如何? 谢谢, KD

【问题讨论】:

  • 标准蓝牙还是蓝牙 LE? Apple 实际上有一个示例应用程序可以为后者展示这一点。

标签: iphone ios objective-c ipad


【解决方案1】:

查看通过蓝牙将数据从一台设备传输到另一台设备的 Apple 示例项目。 BTLE Apple Sample Code

您可以通过RSSI(接收信号强度指示)的值找出信号强度

在示例代码中,您将在收到数据时获得 RSSI 值。在Project中的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 Details on Wiki

希望对你有帮助。

【讨论】:

  • 如果它可以帮助你接受这个答案。这样其他人也可以知道这一点。这也有助于解决他们的问题。
猜你喜欢
  • 1970-01-01
  • 2015-04-11
  • 1970-01-01
  • 1970-01-01
  • 2011-03-02
  • 1970-01-01
  • 1970-01-01
  • 2014-08-16
相关资源
最近更新 更多