我有8个iBeacons,我给了他们所有相同的proximityUUID和不同的主要次要值
但是,当我尝试使用手机查找信标时,其中一些人会发送" rssi"值为0
为什么会这样?
@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
这是日志输出:
proximityUUID:73A7B094-35DD-4B36-A0AA-F11C62E9B4B0
major:0
minor:3
accuracy:-1.000000
proximity:Unknown
rssi:0
答案 0 :(得分:1)
RSSI
是“以信号为单位测量的信标的接收信号强度”。有时候,信标监听器会找到一个信标,但实际上无法确定其RSSI。这就是为什么你的准确性是负面的。 RSSI也是“自上次向您的应用程序报告信标范围以来收到的样本值的平均值。”
此属性中的负值表示无法确定实际精度。
在这种情况下,您可能即将退出信标区域,或者您正处于其范围的边缘。
答案 1 :(得分:0)
似乎RSSI是使用x样本计算的平均值,当iPhone / iPad没有收到此信标的最小样本数量时,它不会计算平均rssi值既不准确,又得到了未知距离。
答案 2 :(得分:0)
我制作了自己的采样器并使用了平均rssi 5秒,如果平均值rssi不为零则忽略零值,因为它必须是噪声数据。