问题
I'm developing an application that will use iBeacons for indoor navigation, and I found that the rate the function locationManager:rangingBeaconsDidFailForRegion:withError:
is being called is not high enough, so I'm going to add the RSSI data from CoreBluetooth's centralManager:didDiscoverPeripheral:advertisementData:RSSI:
.
And I found a curious fact: when I listen to the iBeacon with CoreLocation and log the peripheral id:
- (void)centralManager:(CBCentralManager *)central
didDiscoverPeripheral:(CBPeripheral *)peripheral
advertisementData:(NSDictionary *)advertisementData
RSSI:(NSNumber *)RSSI
{
NSLog(@"%@, RSSI: %@", peripheral, RSSI);
each beacon is reported with different UUID on different devices:
A25804BD-D77A-5004-4C2C-301D996C7367 - my iPhone 5
843F4237-6059-9A5E-AA34-0BD92304BE1F - colleague's iPhone 5
77685805-C253-52BD-B787-8B95308834FB - other colleague's iPad mini
The idea was to bind UUID of each beacon to its location, so this behavior is quite functionality-breaking.
Why the UUID of physically the same beacon (not powered off/on) is different on different devices? Is it an expected behavior? If it is, how could I opt out of it?
回答1:
You cannot read the identifiers of standard iBeacons using CoreBluetooth
. As Chris Stratton said in his comment, the UUID that CoreBluetooth gives you is a device UUID, which is randomly generated on a per-session basis by iOS. It has nothing to do with the iBeacon ProximityUUID.
More details on why you can't read iBeacon identifiers with CoreBluetooth
are here: http://developer.radiusnetworks.com/2013/10/21/corebluetooth-doesnt-let-you-see-ibeacons.html
It is true that you only get on RSSI measurement per locationManager:didRangeBeacons:inRegion:
callback. This is a real obstacle to doing a custom distance estimate. Behind the scenes, iOS can gather 10x as many measurements for iBeacons transmitting at 10Hz. You are correct that you can get more measurements using CoreBluetooth
, but the problem is that there is no reliable way of lining up which bluetooth devices you see with CoreBluetooth
correspond to the iBeacons you can see with CoreLocation
.
来源:https://stackoverflow.com/questions/24265569/uuids-of-ibeacons-are-different-on-different-devices