How does ble beacon example work?

Hello everyone,

I'm trying to understand the code from this example, but one thing that i can't seem to process is how or where does the following structure get hte keys according to its values:


static uint8_t m_beacon_info[BLE_GAP_ADV_SET_DATA_SIZE_MAX] =                    /**< Information advertised by the Beacon. */
{
    APP_DEVICE_TYPE,     // Manufacturer specific information. Specifies the device type in this
                         // implementation.
    APP_ADV_DATA_LENGTH, // Manufacturer specific information. Specifies the length of the
                         // manufacturer specific data in this implementation.
    APP_BEACON_UUID,     // 128 bit UUID value.
    APP_MAJOR_VALUE,     // Major arbitrary value that can be used to distinguish between Beacons.
    APP_MINOR_VALUE,     // Minor arbitrary value that can be used to distinguish between Beacons.
    APP_MEASURED_RSSI,    // Manufacturer specific information. The Beacon's measured TX power in
    //WAIOT_OP_MODE_INIT   // this implementation.
};

Specifically, when I see the beacon on my phone, I can read which parameter is the UUID, which one is Major, which one is Minor, etc, but I cant find how my code knows which parameter is each one. I have this doubt because I'm trying to replace one of those parameters and change its key/name.

SDK: v17.1

SoftDevice: S132

Thanks for your help

Parents
  • Hi,

    The beacon sample is based on Apple iBeacon, so you can refer to Apple's documentation for details. Other than that, the comments where the array is populated that you copy-pasted in your original post describe it in detail.

    Specifically, when I see the beacon on my phone, I can read which parameter is the UUID, which one is Major, which one is Minor, etc, but I cant find how my code knows which parameter is each one.

    The format of this beacon (iBeacon type) is always the same, and as you see in the code. That hard codes everything. It is a standard legacy advertising packet with manufacturer specific data and length fields for that, which follows the Bluetooth specification. The content of the manufacturer specific data is that of iBeacon, and you need to know the format in order to decode it (which you do from the comments in the code or Apple's documentation).

  • I'm not sure if i correctly understood you. Does nRF Connect just process the beacon? I initially thought the example beacon sent each value with it's key in some way, but is nRF Connect just getting the whole message and deciding which one is each (according to a standard)?

Reply Children
Related