Search code examples
swiftcore-locationdetectionbeaconrssi

Beacon Detection in Swift


I am building an app in swift that helps me detect beacons and display their RSSI values. I was using the native CoreLocations library from apple to detect beacons but noticed that the rate of detection is set to 1 second and it cannot be changed. Is there a way to reduce the detection interval to say 100-500ms so that I can get more RSSI values?


Solution

  • You can also use CoreBluetooth APIs to detect beacons, which give you a separate RSSI measurement for each packet detected. For a beacon advertising at 10 times per second, this would give you an RSSI update approximately every 100ms.

    There are two big catches to using CoreBluetooth:

    1. It cannot detect iBeacon because Apple blocks it. CoreBluetooth can detect AltBeacon and Eddystone.

    2. The API is harder to use with beacons — you have to parse out the identifiers from the packets manually.

    Also, be aware that the RSSI value returned by CoreLocation once per second is actually an average based on all packets received over the previous second, so it is more stable than individual samples taken at a higher frequency. Depending on what you want the samples for, you may find the higher variation is a problem.

    Finally, be aware that the max rate at which you get samples with CoreBluetooth depends on the beacon transmission rate. Some beacons advertise only once per second. If you are working with such a beacon, you will not get any more samples with CoreBluetooth.