CLBeacon-如何更改rssi(主要和次要)? [英] CLBeacon - how to change rssi, major and minor?

查看:168
本文介绍了CLBeacon-如何更改rssi(主要和次要)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题基本上是-如何修改iBeacon的默认设置,例如大,小和RSSI?

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

推荐答案

根据iBeacon的含义,可以使用不同的方法来设置这些值:

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

  1. 硬件信标

  1. Hardware iBeacons

每个信标供应商都有不同的方法来设置这些值.有些更改是通过通常由专有iOS或Android应用程序管理的蓝牙服务进行的. (示例包括 Radius Networks '电池供电的USB信标和 PiBeacon 包含一个带有可编辑文件包含标识符.其他供应商(例如Estimote)使用无法更改的固定UUID创建信标.因为没有标准的机制,所以没有通用的工具可以在所有信标类型上设置标识符.

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.

iOS软件iBeacons:

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];

  • iOS CLBeacon

    CLBeacon类并非旨在由用户创建或修改的-当它检测到iBeacons时,应该由CoreLocation构造.也就是说,您可以 使用KVO语法强制写入其只读属性,如下所示:

    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);
    

    但是,如果您强迫CLBeacon类以某种不被设计为使用的方式使用,则可能意味着您做错了事.

    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.

    完全公开:我为Radius Networks工作.

    Full disclosure: I work for Radius Networks.

    这篇关于CLBeacon-如何更改rssi(主要和次要)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆