This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

AN36 modifications

I want to add to lbs service battery service(bas) as well. One of the changes is in the advertising_init() function:


static void advertising_init(void)
{
    uint32_t      err_code;
    ble_advdata_t advdata;
    uint8_t       flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
    ble_uuid_t adv_uuids[] = 
    {
        {BLE_UUID_BATTERY_SERVICE, m_lbs.uuid_type},
        {LBS_UUID_SERVICE, m_lbs.uuid_type}
    };

    // Build and set advertising data
    memset(&advdata, 0, sizeof(advdata));
    
    advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance      = true;
    advdata.flags.size              = sizeof(flags);
    advdata.flags.p_data            = &flags;
    advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = adv_uuids;
    
    err_code = ble_advdata_set(&advdata, NULL);
    APP_ERROR_CHECK(err_code);
}

As a result I have NRF_ERROR_DATA_SIZE I did use blood pressure service as an example. What did I miss?

Thank you.

Parents
  • Thank you for the reply. I do not understand what this exactly means:> I dropped the other services and pared the name down.

    Also, I'm aware of size limitations but how does ble_advdata_t is converted into the message, so I can count it's size? Sorry I didn't find this in ble_advdata.h. How to split correctly long message between the advertisement package and the scan response. Could you please point me to an example.

    Thank you.

  • I assume the user who wrote that means that he removed some of the services and then shortened his name.

    There isn't any magic way to know how large the packet is, but if you look at the source code for ble_advdata, you can see the raw packet as passed to sd_ble_advdata_set(). This is the size of advertising data as seen on air. You can also take a look at the Core Specification, Volume 3, Part C, chapter 11, which details the different fields available.

    There isn't any right or wrong way to separate data between the advertisement packet and scan response, you are more or less free to choose as you see fit. The only exception I'm aware of is that you are allowed to have the name only one place, and that the Flags field shall be in the advertisement. You may also want to consider Apple's recommendations in section 3.4 of their Bluetooth Accessory Design Guidelines, if that is a target platform of yours: https://developer.apple.com/hardwaredrivers/bluetoothdesignguidelines.pdf

Reply
  • I assume the user who wrote that means that he removed some of the services and then shortened his name.

    There isn't any magic way to know how large the packet is, but if you look at the source code for ble_advdata, you can see the raw packet as passed to sd_ble_advdata_set(). This is the size of advertising data as seen on air. You can also take a look at the Core Specification, Volume 3, Part C, chapter 11, which details the different fields available.

    There isn't any right or wrong way to separate data between the advertisement packet and scan response, you are more or less free to choose as you see fit. The only exception I'm aware of is that you are allowed to have the name only one place, and that the Flags field shall be in the advertisement. You may also want to consider Apple's recommendations in section 3.4 of their Bluetooth Accessory Design Guidelines, if that is a target platform of yours: https://developer.apple.com/hardwaredrivers/bluetoothdesignguidelines.pdf

Children
No Data
Related