在IOS中,如何基于RSSI连接最近的蓝牙设备

时间:2017-09-06 09:02:21

标签: ios objective-c iphone core-bluetooth

在didDiscoverPeripheral方法中,我有扫描设备的外围设备,RSSI。但我需要根据RSSI值选择最近的蓝牙设备。我能够获得最近的RSSI值,但我无法将RSSI映射到Peripheral.Can任何人都可以帮助我。

- (void)centralManager:(CBCentralManager )central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { 
    ScannedPeripheral sensor = [ScannedPeripheral initWithPeripheral:peripheral rssi:RSSI.intValue isPeripheralConnected:NO];
    sensor.RSSI = [RSSI intValue]; 
    [self.Arr addObject:[NSString stringWithFormat:@"%d",sensor.RSSI]];
    NSArray *qwe = [self.Arr sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2){ return [obj1 compare:obj2];}];
}

0 个答案:

没有答案