美文网首页蓝牙协议
iOS 设备之间的蓝牙信号强度

iOS 设备之间的蓝牙信号强度

作者: 清风_____ | 来源:发表于2021-01-19 11:28 被阅读0次

    RSSI.integerValue

    - (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];
        }
    }
    

    相关文章

      网友评论

        本文标题:iOS 设备之间的蓝牙信号强度

        本文链接:https://www.haomeiwen.com/subject/fneqzktx.html