2

Beacon Proximity range changes the proximity response as Near - Immediate - Far, even while the ios Device remains in the same place.

As I open a view when the proximity response is Near. I get the proximity response back and forth, Near - immediate then Near. It shows up the view again and again

How can we solve this issue. Is there any event handler.

Thanks.

Srivathsava K
  • 437
  • 2
  • 5
  • 15

2 Answers2

3

The proximity and accuracy values appear to be quite 'noisy'. It can also depend on your environment. Water (and therefore people) absorbs the frequencies used by Bluetooth so people moving can have an impact, but I observe variation in between 1.2m and 1.9m when both devices are sitting on my desk.

I think you are going to have to deal with the noise in your app. Once a view has opened you should keep it open until the beacon is 'far' (or you get a region exit) for some period of time. If the state transitions back to near or immediate then reset the timer.

You need to use some code similar to the following -

-(void)locationManager:(CLLocationManager *)manager
    didRangeBeacons:(NSArray *)beacons
           inRegion:(CLBeaconRegion *)region {

    CLBeacon *beacon=beacons[0];

    switch (beacon.proximity) {

    case CLProximityFar:
        if (self.farTimer==nil) {
            self.farTimer=[NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(farTimerFired:) userInfo:beacon repeats:NO];
        }
    break;

    case CLProximityNear:
    case CLProximityImmediate:
        if (self.farTimer!=nil) {
            [self.farTimer invalidate];
            self.farTimer=nil;
        }
    break;

    case CLProximityUnknown:
         NSLog(@"Beacon proximity is unknown");
    break;
   }
}

-(void) farTimerFired:(NSTimer *)timer {
 CLBeacon *beacon=(CLBeacon *)timer.userInfo;
 NSLog(@"Beacon %@ is really far",beacon.proximityUUID.UUIDString);
 self.farTimer=nil;
}
Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • The problem I have seen is when I keep the beacon and iOS device both side by side which is immediate proximity but still the problem occurs . It changes the proximity to Immediate after some seconds to NEAR proximity. – Srivathsava K Mar 25 '14 at 08:46
  • 1
    Which is fine, because immediate is closer than near. Once you have triggered at "near" you need to watch for state changes to "far" (or region exited). When you get a "far" start a timer - if you are still at "far" for some period, then you are 'really' far. If you go back to near or immediate then reset the process – Paulw11 Mar 25 '14 at 08:50
  • how can i start a timer on far ? I tryed in many ways but didRangeDelegate call near or immediate even if the timer is started. It work if u call an another view with perfomsegue with delay. But if you want to stay on the same View ? How can i do please ? – mad_mask Feb 05 '15 at 01:54
  • 1
    @mad_mask see the sample code I added to the answer – Paulw11 Feb 05 '15 at 03:19
  • Thank you so much Paulw11. I will try this today. – mad_mask Feb 05 '15 at 12:14
  • Ok All works perfectly. i have understand. :) Thanks again. Now i have to calibrate each beacon correcly to avoid zones overlap. But can you explane me how i can do to avoid these overlap if i want one of my beacons to be set for notification with a range of 30 feet (+4db) ? – mad_mask Feb 07 '15 at 15:14
1

Understand that the proximity value is just an estimate based on radio signal strength, so this is expected behavior due to noise as @Paulw11 says in his answer.

Two things you can do to make the proximity (and accuracy) readings as solid as possible:

  1. Choose an iBeacon with as fast of a transmission rate as possible. Different ibeacons transmit advertisements at different frequencies from 30 times per second to once per second or less. Generally, faster transmission rates give you less noisy distance estimates because they give iOS more radio signal strength measurements to work with. For your testing, Try an iOS-based iBeacon like Locate for iBeacon to see if it helps. It is known to transmit 30x per second.

  2. Make sure your iBeacon is properly calibrated. This will not reduce the noise, but it will make sure the readings you get are correct as possible on average. If not properly calibrated you may see jumps between immediate and near more often when the device is solidly in the immediate zone, because it is calculating the distance as too far away.

Beyond this, A software filter on the proximity value might help as @Paulw11 suggests, but it still won't be perfect. You simply have to decide if you can live with the noise for your use case.

Community
  • 1
  • 1
davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Can we go with the RSSI value / Accuracy for measuring the distance of the Beacon instead of Proximity(FAR, NEAR, IMMEDIATE). – Srivathsava K Mar 27 '14 at 06:27
  • Yes, but this will not help the noise problem. The Proximity field (FAR, NEAR, IMMEDIATE) simply groups the Accuracy field value into predefined buckets. And the RSSI field is even more noisy, because it has no software filter on it like Accuracy does. The Accuracy field uses a running average of RSSI over about 30 secs. – davidgyoung Mar 27 '14 at 09:28
  • Can we use accelerometer to get the rolling averages. Is that possible. – Srivathsava K Apr 08 '14 at 10:47
  • Adding accelerometer data might be useful to a custom algorithm in very specific motion-based use cases, but probably is not helpful in the primary use case where the user is standing still. If the user is standing still, the best you can do is take a longer rolling average. You can collect a long set of RSSI averages then use an algorithm to compute distance like here: http://stackoverflow.com/questions/20416218/understanding-ibeacon-distancing – davidgyoung Apr 08 '14 at 12:11