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

Measure the length of the advertisement buffer

Hi,

How do I measure the length of the created advertisement buffer?  I want to add two UUIDs in the packet and the device is resetting. I guess the length is the issue.

// YOUR_JOB: Use UUIDs for service(s) used in your application.
static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifiers. */
{
{BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE},
{BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}
}; 

This does not work. If I comment out the second UUID, then only it works.

The debug does not show any error.

ready<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => ready
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => ready
0> <d<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x000229<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => ready
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => re<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: S<info> app_timer: RTC: initialized.
0> <debug> nr<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 =<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => ready
0> <debug<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => ready<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sd<info> app_timer: RTC: initialized.
0> <debug> nrf_sd<info> app_timer: RTC: initialized.
0> <debug> nrf_sd<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => re<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => ready
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x000229<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer 0x00022910 => ready<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <info> app_timer: RTC: initialized.
0> <debug> nr<info> app_timer: RTC: initialized.
0> <debug> nrf_sdh: State request: 0x00000000
0> <debug> nrf_sdh: Notify observer

Parents
  • Hi,

    the device is resetting

    Usually that happens because you entered the app_error_fault_handler(). If you are using SES, use the Debug configuration:

    How do I measure the length of the created advertisement buffer?

    As far as I know, there is no function to get the current length. If you try to add too much data, ble_advertising_init() will return NRF_ERROR_DATA_SIZE.

    This does not work. If I comment out the second UUID, then only it works.

    Try adding the UUIDs to the scan response data instead of advdata, snippet from advertising_init():

        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;

     

Reply
  • Hi,

    the device is resetting

    Usually that happens because you entered the app_error_fault_handler(). If you are using SES, use the Debug configuration:

    How do I measure the length of the created advertisement buffer?

    As far as I know, there is no function to get the current length. If you try to add too much data, ble_advertising_init() will return NRF_ERROR_DATA_SIZE.

    This does not work. If I comment out the second UUID, then only it works.

    Try adding the UUIDs to the scan response data instead of advdata, snippet from advertising_init():

        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;

     

Children
No Data
Related