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
  • I'm assuming that > the source code for ble_advdata you mean file ble_advdata.c but in any case I do not see sd_ble_advdata_set(): not in this file nor anywhere else. Also there is a function sd_ble_gap_appearance_get(). Should it not return what sd_ble_gap_appearance_set() sets? Template uses

    
        /* YOUR_JOB: Use an appearance value matching the application's use case.
        err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_);
        APP_ERROR_CHECK(err_code); */
    
    

    AN36 doesn't have this snippet or I missed it but somehow appearance gets initialized to 0x1234 and the code is not for debugging... I'm sorry for the next question because I'm sure BLE Core v.4 has the answer but having advertisement package and the scan response limits is limiting to less than 62 bytes. What am I missing? Or if it is necessary one can modify ads by changing my advertisement data?

    Thanks.

  • Sorry, the method name was a typo from my part, it is sd_ble_gap_adv_data_set(), which as you can see is the final call of ble_advdata_set().

    It seems that current softdevices will initialize the appearance to 0x1234, but this will most likely be changed in future versions to just 0. If you want to, you can set appearance to one of the values from this list: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml

    As for the latter part of your question, I'm not sure I understand it. With the S110, you can change the advertising data at any time, by either calling sd_ble_gap_adv_data_set() or ble_advdata_set(). You can however not advertise more than 31 bytes in the advertisement packet and 31 bytes in the scan response, and all data must be part of some advertising type as defined in the specification.

Reply Children
No Data
Related