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
  • If you want to advertise a regular Bluetooth SIG service like the battery service, you should use BLE_UUID_TYPE_BLE and not m_lbs.uuid_type. Using the latter will set the Battery Service's 16-bit UUID on top of the Led Button service's base UUID, which is not what you want.

    The error 0x0C shows that your advertisement packet is too big. For details, take a look at this and this question, and also section 4.4.6 of the application note.

Reply
  • If you want to advertise a regular Bluetooth SIG service like the battery service, you should use BLE_UUID_TYPE_BLE and not m_lbs.uuid_type. Using the latter will set the Battery Service's 16-bit UUID on top of the Led Button service's base UUID, which is not what you want.

    The error 0x0C shows that your advertisement packet is too big. For details, take a look at this and this question, and also section 4.4.6 of the application note.

Children
No Data
Related