iphone - iphone 设备之间的蓝牙信号强度

标签 iphone ios objective-c ipad

我有两个通过蓝牙连接的 iPhone 设备。是否有可能在这些设备之间获得信号强度?如果可能的话,怎么样? 谢谢, K.D

最佳答案

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

可以通过RSSI(Received signal strength indication)的值来判断信号强度

在示例代码中,您将在收到数据时获得 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

希望对你有帮助

关于iphone - iphone 设备之间的蓝牙信号强度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14588699/

相关文章:

php - 使用我的 iphone 应用程序中的 php 将字符串(带空格)插入 mysql

objective-c - 在 Cocoa 中使用 NSTimer 关闭自定义 NSPanel

iOS:如何关闭显示的 Leadbolt 广告的添加事件?

iOS SDK-如何获取 viewController 的 segue 标识符?

ios - 无法将NSData转换为int

ios - 如何将UIView添加到所有 View 的顶部

iphone - 在 iPhone 应用程序中旋转 MKMapView

iphone - 泛化对 NSLog 的调用

ios - 在 ios 应用程序中使用 svg 或字体图标

ios - 在 uisearchDisplayController '是结果中,如何突出显示在搜索栏中输入的字符串?