Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Created July 27, 2018 08:33
Show Gist options
  • Save SunXiaoShan/cf0047fe62140e1f06066ef11fb428e7 to your computer and use it in GitHub Desktop.
Save SunXiaoShan/cf0047fe62140e1f06066ef11fb428e7 to your computer and use it in GitHub Desktop.
- (void)centralManager:(CBCentralManager *)central
didDiscoverPeripheral:(CBPeripheral *)peripheral
advertisementData:(NSDictionary *)advertisementData
RSSI:(NSNumber *)RSSI {
if ([self isIgnorePeripheral:RSSI]) {
return;
}
if (peripheral) {
if (![self.peripherals containsObject:peripheral]) {
[self.peripherals addObject:peripheral];
}
[self.centralManager connectPeripheral:peripheral options:nil];
}
}
- (BOOL)isIgnorePeripheral:(NSNumber *)RSSI {
// Received Signal Strength Indicator
if (RSSI.integerValue > -15) {
return YES;
}
if (RSSI.integerValue < -60) {
return YES;
}
return NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment