Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I measure Bluetooth signal strength in iOS?

Can I measure the signal strength of Bluetooth devices within range of my iPhone?

Basically what I want to do is scan for a list of devices within range, and then see which one has the highest signal strength.

Is it possible in iOS and how would I do it if so?

like image 567
Samuel Rosen Avatar asked Oct 23 '12 02:10

Samuel Rosen


2 Answers

Yes there is a way to measure the signal strength for Bluetooth Low Energy (4.0) it is the RSSI number. When you scan for peripherals you will set the flag CBCentralManagerScanOptionAllowDuplicatesKey to YES as shown below:

NSDictionary * dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@YES, CBCentralManagerScanOptionAllowDuplicatesKey, nil];

// Start scanning for peripherals
[cmanager scanForPeripheralsWithServices:nil options:dictionary];

If you want to see the RSSI number work without writing any code you should check out the app LightBlue in iTunes. When you connect to a peripheral it will show you the updated RSSI number every second when it is connected.

like image 118
kevinejohn Avatar answered Sep 21 '22 20:09

kevinejohn


Have a look to the CoreBluetooth documentation:

- (void)centralManager:(CBCentralManager *)central 
 didDiscoverPeripheral:(CBPeripheral *)peripheral 
     advertisementData:(NSDictionary *)advertisementData 
                  RSSI:(NSNumber *)RSSI
{ ... }

RSSI is what you are looking for. Disclaimer: Core Bluetooth is made for Bluetooth 4 LE only.

If the exact range does not matter, but you are interested in scanning devices which are available in general, you may have a look to the github project BeeTee, which allows you to scan for all Bluetooth devices around you (not only Bluetooth LE). Again disclaimer: I am the author of BeeTee. ;-)

like image 36
Michael Dorner Avatar answered Sep 20 '22 20:09

Michael Dorner