Reputation: 13947
I have 8 iBeacons and i gave them all the same proximityUUID and different major minor values
however, when i try to use the phone to find the beacons, some of them send "rssi" value of 0
why is that ?
@implementation CLBeacon(description)
-(NSString *)stringProximity{
switch (self.proximity) {
case CLProximityUnknown:
return @"Unknown";
case CLProximityImmediate:
return @"less than 0.5 meters away";
case CLProximityNear:
return @"0.5<distance<4 meters away";
case CLProximityFar:
return @"more than 4 meters away";
}
return @"";
}
-(NSString *)UUIDString{
NSMutableString *string = [[[self proximityUUID]UUIDString]mutableCopy];
[string replaceOccurrencesOfString:@"-" withString:@"-\n" options:0 range:NSMakeRange(0, [string length])];
return string;
}
-(NSString *)describe{
NSString *contents = [NSString stringWithFormat:@"proximityUUID:%@\nmajor:%@\nminor:%@\naccuracy:%f\nproximity:%@\nrssi:%ld",[self UUIDString],[self major],[self minor],[self accuracy],[self stringProximity],[self rssi]];
return contents;
}
@end
@implementation WBBeaconManager
-(id)init{
self = [super init];
if(self){
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self initRegion];
[self locationManager:self.locationManager didStartMonitoringForRegion:self.beaconRegion];
}
return self;
}
- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region {
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
}
- (void)initRegion {
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:BEACONUUID];
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:BEACONIDENTIFIER];
[self.locationManager startMonitoringForRegion:self.beaconRegion];
}
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
NSLog(@"Beacon Found");
[self makeText:[NSString stringWithFormat:@"entered region:%@",region.identifier ]];
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
[self makeText:[NSString stringWithFormat:@"entered region: %@",region.identifier]];
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
NSLog(@"Left Region");
[self makeText:[NSString stringWithFormat:@"left region:%@",region.identifier ]];
[self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
[self makeText:[NSString stringWithFormat:@"left region: %@",region.identifier]];
// self.beaconFoundLabel.text = @"No";
}
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
CLBeacon *beacon = [beacons firstObject];
for(CLBeacon *b in beacons){
LogInfo(@"%@",[b describe]);
}
// if(beacon.proximity == CLProximityNear || beacon.proximity == CLProximityImmediate){
[self makeText:[beacon describe]];
// }
}
-(void)dealloc{
[self.locationManager stopMonitoringForRegion:self.beaconRegion];
[self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
}
@end
and here is the log output:
proximityUUID:73A7B094-35DD-4B36-A0AA-F11C62E9B4B0
major:0
minor:3
accuracy:-1.000000
proximity:Unknown
rssi:0
Upvotes: 4
Views: 3914
Reputation: 449
I made my own sampler and used average rssi for 5 seconds and ignored zero value if average rssi is not zero because it must be noise data.
Upvotes: 0
Reputation: 53132
The RSSI
is the "received signal strength of the beacon, measured in decibels." Sometimes a beacon listener will find a beacon, but can't actually determine its RSSI. This is why your accuracy is negative. The RSSI is also an average of "the values of the samples received since the range of the beacon was last reported to your app."
A negative value in this property signifies that the actual accuracy could not be determined.
In this case, you are probably about to exit the beacon region, or you are right on the fringe of its range.
Upvotes: 2
Reputation: 1866
Seems like RSSI is a mean value computed using x samples, when the iPhone/iPad does not receive a minimum amount of samples for this beacon it doesn't compute the mean rssi value neither the accuracy, and you got an Unknown proximity.
Upvotes: 1