locationManager:didRangeBeacons:inRegion beacon array contains multiple instances of the same beacon

307 Views Asked by At

So I have my delegate method locationManager:didRangeBeacons:inRegion and it gives me an NSArray of beacons. Usually it only has 1 beacon in the array, that is the one I'm currently searching for. However it happens sometimes where there are multiple beacons in the array, all with the same information. It gives the same major, minor and UUID, but completely different distance readings.

There's definitely not 6 different beacons with the minor 221, but sometimes it will show up in the NSArray 6 times. Some of the distance results in the array it's giving are completely inaccurate, while others aren't bad, so I'm not sure why the completely inaccurate results are even in there in the first place.

The code inside locationManager:didRangeBeacons:inRegion is below:

-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
    if(beacons.count>0) {
        for(int i = 0; i < beacons.count; i++) {
            NSLog(@"Beacon #%d: %@", i, [beacons objectAtIndex:i]);
        }
        CLBeacon *beacon = [[CLBeacon alloc] init];
        beacon = [beacons lastObject];

        NSLog(@"%f", beacon.accuracy);
        if(beacon.accuracy != -1.0){
            unknownCounter = 0;
            activityView.hidden = YES;
            if(searching){
                controlView.hidden = NO;
            }
            [self determineHotColdBarColor:beacon.accuracy];
        }
    }else{
        NSLog(@"Couldn't find any beacons");
    }
}

And here's the log I got when it found the same beacon information 6 times:

2015-09-21 12:49:31.327 My Beacon App[441:88487] Beacon #0: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a380> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.328 My Beacon App[441:88487] Beacon #1: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a3c0> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.328 My Beacon App[441:88487] Beacon #2: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a020> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.328 My Beacon App[441:88487] Beacon #3: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a060> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:0 +/- -1.00m, rssi:0)
2015-09-21 12:49:31.329 My Beacon App[441:88487] Beacon #4: CLBeacon (uuid:<__NSConcreteUUID 0x1d91a0a0> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:2 +/- 0.35m, rssi:-52)
2015-09-21 12:49:31.331 My Beacon App[441:88487] Beacon #5: CLBeacon (uuid:<__NSConcreteUUID 0x1d919fe0> 6CE21B2C-FD69-49CD-B375-578943BC4678, major:2, minor:221, proximity:2 +/- 0.41m, rssi:-52)

If anyone has any idea why something like this would be happening I would greatly appreciate it. Thank you!

0

There are 0 best solutions below