问题
iBeacons seem to broadcast their txPower parameter (report RSSI power at 1 meter distance) which is used in calculating beacon.accuracy
and beacon.proximity
properties (details on iBeacon advertisements packet can be found here).
However, CLBeacon
class does not seem to have a property for txPower. Is there a way I can get txPower using Core Location framework, or need I to go down to Core Bluetooth? The reason I need this, is I want to experiment with custom beacon accuracy/proximity calculation for very quick beacon immediate range discovery. In this circumstances reverse calculating txPower from accuracy
is no helper.
回答1:
Unfortunately you can not get this value programmatically with either CoreLocation
or CoreBluetooth
. Apple blocks access to all iBeacon data with CoreBluetooth
(See my breakdown of this here.) Similarly with CoreLocation
it is simply not exposed in the CLBeacon
class as you have seen.
Since you say you can't to do a reverse-calculation, then the only other ways I can think of to do this are:
- Use an Android, OSX Mavericks, or Linux device, which offer no such restrictions on reading this field.
- Make a lookup table in your iOS app of all your iBeacons (with unique UUID/major/minor values vs. their txPower value)
Option 2 above obviously requires that you assign unique identifiers to all your iBeacons under test.
来源:https://stackoverflow.com/questions/24001702/ibeacons-how-to-get-broadcasted-beacon-power-txpower