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
  • This is what I ended up with:

    
    static void advertising_init(void)
    {
        uint32_t      err_code;
        ble_advdata_t advdata, scanrsp;
        uint8_t       flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
        
        // YOUR_JOB: Use UUIDs for service(s) used in your application.
        ble_uuid_t adv_uuids[] = 
        {
            {BLE_UUID_BATTERY_SERVICE, BLE_UUID_TYPE_BLE},
            {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;
    
        memset(&scanrsp, 0, sizeof(scanrsp));
        scanrsp.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
        scanrsp.uuids_complete.p_uuids  = adv_uuids;
        
        err_code = ble_advdata_set(&advdata, &scanrsp);
        APP_ERROR_CHECK(err_code);
    }
    
    

    Does this mean that because of implementation of SD110 x.uuids_complete can not be splitted between advdata and scanrsp?

  • You can get any kind of advertisement and scan response data you want, by just using sd_ble_gap_adv_data_set() directly if ble_advdata doesn't allow you to do what you want. In that case, you must however do the parsing and data setup yourself.

    Based on my understanding of the spec however, I don't think it would normally be legal to have uuids_complete split between advertisement data and scan response. The reason is that each packet should be valid in itself, but if you have only some services in a field marked as uuid_complete, your field doesn't actually contain what the type implies. If you want to share the list between the packets, I'd therefore recommend you to use more_available.

    (In your case this is somewhat different, since you have one 128-bit UUID and one 16-bit UUID, so you could probably achieve what you want and be compliant by having the type of fields be different (see Core specification, Volume 3, Part C, table 18.2), but this seems to be a corner case.)

Reply
  • You can get any kind of advertisement and scan response data you want, by just using sd_ble_gap_adv_data_set() directly if ble_advdata doesn't allow you to do what you want. In that case, you must however do the parsing and data setup yourself.

    Based on my understanding of the spec however, I don't think it would normally be legal to have uuids_complete split between advertisement data and scan response. The reason is that each packet should be valid in itself, but if you have only some services in a field marked as uuid_complete, your field doesn't actually contain what the type implies. If you want to share the list between the packets, I'd therefore recommend you to use more_available.

    (In your case this is somewhat different, since you have one 128-bit UUID and one 16-bit UUID, so you could probably achieve what you want and be compliant by having the type of fields be different (see Core specification, Volume 3, Part C, table 18.2), but this seems to be a corner case.)

Children
No Data
Related