CLBeacon - how to change rssi, major and minor?

萝らか妹 提交于 2019-12-09 01:47:25

问题


My question is basically - how do I get to modify iBeacon's default settings like major, minor and RSSI?


回答1:


There are different ways to set these values depending on what you mean by an iBeacon:

  1. Hardware iBeacons

    Each Beacon vendor has different ways of setting these values. Some are changed via a bluetooth service that is typically managed with a proprietary iOS or Android app. (Examples include Radius Networks' battery-powered and USB beacons and TwoCanoes beacons.) Radius Networks' PiBeacon includes an SD card with an editable file containing the identifiers. Other vendors like Estimote create beacons with fixed UUIDs that cannot be changed. Because there is no standard mechanism, there is no universal tool for setting identifiers on all beacon types.

  2. iOS Software iBeacons:

    You set these values with code like below:

    CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"] major:1 minor:1 identifier:@"com.radiusnetworks.iBeaconExample"];
    NSDictionary *peripheralData = [region peripheralDataWithMeasuredPower:-55];
    [_peripheralManager startAdvertising:peripheralData];
    
  3. The iOS CLBeacon class

    The CLBeacon class is not designed to be created or modified by the user -- it is supposed to be constructed by CoreLocation when it detects iBeacons. That said, you can force writing to its read-only properties using KVO syntax like so:

    CLBeacon * iBeacon = [[CLBeacon alloc] init];
    [iBeacon setValue:[NSNumber numberWithInt:1] forKey:@"major"];
    [iBeacon setValue:[NSNumber numberWithInt:1] forKey:@"minor"];
    [iBeacon setValue:[NSNumber numberWithInt:-55] forKey:@"rssi"];
    [iBeacon setValue:[[NSUUID alloc] initWithUUIDString:@"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"] forKey:@"proximityUUID"];
    NSLog(@"I constructed this iBeacon manually: %@", iBeacon);
    

    However, if you are forcing the CLBeacon class to be used in ways it was not designed to be used that might mean you are doing something wrong.

Full disclosure: I work for Radius Networks.




回答2:


When you initialize a CLBeaconRegion object you can specify Major and Minor variables. Took a look at initWithProximityUUID:major:minor:identifier method.

As far as am aware ones a beacon active your cannot change it value unless you recreate that object. Rssi represents signal strength of the beacon which is only read-only and depends on the environment.

Here the link for the (documentation](https://developer.apple.com/library/iOs/documentation/CoreLocation/Reference/CLBeaconRegion_class/Reference/Reference.html#//apple_ref/doc/uid/TP40013054)



来源:https://stackoverflow.com/questions/20762695/clbeacon-how-to-change-rssi-major-and-minor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!