Reputation: 5629
I am working on a project where I first wanted to advertise a device as an iBeacon and make it possible to connect to that device via Core Bluetooth at the same time. Besides the fact that this is not easily doable (a device cannot advertise as an iBeacon and CB device at the same time), I noticed that the iBeacon part seems unnecessary - discovering peripherals with Core Bluetooth seems to be basically the same as discovering iBeacons.
My first Question: Am I right in assuming this? Or does iBeacon provide anything that central/peripherals in CB do not? Especially in regard to background advertisement/searching?
The only issue I can see right now is that the CLBeacon
gives me both an rssi
and an accuracy
(and from this, the approximated proximity
is calculated). With Core Bluetooth, centralManager:didDiscoverPeripheral:advertisementData:RSSI:
gives me only an RSSI. Is there any way to retrieve the accuracy here so I can calculate a proximity? This is important for me and I guess relying on RSSI only for the proximity will give me less accurate results?
My second Question: Can I get the accuracy
that I get with iBeacon in Core Bluetooth or a similar measure to calculate the proximity?
Upvotes: 3
Views: 2099
Reputation: 65005
You can calculate your own distance estimate with RSSI using an algorithm like the one I posted here:
https://stackoverflow.com/a/20434019/1461050
The trick is that you will need as many RSSI measurements as possible averaged over a time window of 20 seconds or so to reduce the noise on the estimate.
The main advantages of using CoreLocation
APIs to detect standard iBeacons vs. using CoreBluetooth
to detect custom beacons are:
CoreLocation
can scan for iBeacons in the background (likely using hardware assist on iPhone 5+) in a way that can automatically launch your app relatively quickly, even if the user did not manually launch it since boot. As of iOS 7.1, even if the user kills the app from the task switcher, CoreLocation
can re-launch it into the background if an iBeacon is detected. I do not believe all this is possible with CoreBluetooth
.Upvotes: 4