5

我周围有几个 nRF51822 传感器,我想开始使用 iOS iBeacon 设置。我遇到的问题是为了做

- (id)initWithProximityUUID:(NSUUID *)proximityUUID identifier:(NSString *)identifier;

你需要知道传感器的proximityUUID。查看 CLBeacon 文档,这似乎是传感器的只读属性,但是我如何/在哪里从

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI

我看到 kCBAdvDataServiceUUID 带有一个 2500 的字符串,但我不认为就是这样。任何人有任何方向或见解?

谢谢

4

3 回答 3

4

您可能还可以查看此代码片段,该代码片段首先在 Nordic 自己的问答网站上共享

typedef __packed struct
{
    uint16_t unknown1;
    uint8_t uuid[16];
    uint16_t major;
    uint16_t minor;
    uint8_t unknown2;
} clbeacon_info_t;
...
static void advertising_init(void)
{
    uint32_t      err_code;
    uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    ble_advdata_t advdata;

    uint8_t uuid[16] = {0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0};

    clbeacon_info_t beacon_info;
    beacon_info.unknown1 = 0x1502;
    memcpy(&beacon_info.uuid, &uuid, sizeof(uuid));
    beacon_info.major = 0x3412;
    beacon_info.minor = 0x7798;
    beacon_info.unknown2 = 0xC5;

    ble_advdata_manuf_data_t manuf_specific_data;
    manuf_specific_data.company_identifier = 0x004C;
    manuf_specific_data.data.p_data        = (uint8_t *) &beacon_info;
    manuf_specific_data.data.size          = sizeof(beacon_info);

    // Build and set advertising data
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type               = BLE_ADVDATA_NO_NAME;
    advdata.flags.size              = sizeof(flags);
    advdata.flags.p_data            = &flags;
    advdata.p_manuf_specific_data   = &manuf_specific_data;

    err_code = ble_advdata_set(&advdata, NULL);
    APP_ERROR_CHECK(err_code);
}


/**@brief Start advertising.
 */
static void advertising_start(void)
{
    uint32_t             err_code;
    ble_gap_adv_params_t adv_params;

    // Start advertising
    memset(&adv_params, 0, sizeof(adv_params));

    adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
    adv_params.p_peer_addr = NULL;
    adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    adv_params.interval    = APP_ADV_INTERVAL;
    adv_params.timeout     = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = sd_ble_gap_adv_start(&adv_params);
    APP_ERROR_CHECK(err_code);
    nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO);
}

...
于 2013-10-28T07:39:55.807 回答
2

UUID 必须在 BLE 设备的广告数据中设置 是一篇描述广告包逆向工程的博客文章。使用这种格式,您可以为被 iOS 识别为 iBeacon 的 BLE 传感器制作固件。

一旦你有一个工作的信标硬件,你知道它的 UUID,你可以- (void)startMonitoringForRegion:(CLRegion *)regionCLLocationManager

于 2013-10-17T09:14:39.223 回答
1

您使用 nRF51822 传感器构建的设备将通过 iBeacon 协议宣传接近 UUID,据我了解,该协议尚未发布。在那之前,玩游戏的最简单方法是使用另一台宣传其存在的 iOS 设备。UUID 本身是定义的东西。

本文很好地概述了您需要做什么。

于 2013-09-24T20:55:02.793 回答