how to reduce advertising packet length?

Hello,

I used the NRF52810 controller for BLE application. I have a code in which BLE advertising packet length is 32 byte i have to reduce it to 23 bytes

Following is buffer which store advertising data.

uint8_t BC_advertData[31] =
{
0x02,   // length of this data      
GAP_ADTYPE_FLAGS,                    //GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
0x04,
0x03,   // length of this data          
GAP_ADTYPE_16BIT_MORE,      // some of the UUID's, but not all 
LO_UINT16(Default_UUID),            
HI_UINT16(Default_UUID),            
0x17, // length of this data including the data type byte       // [7]
GAP_ADTYPE_MANUFACTURER_SPECIFIC, // manufacturer specific adv data type // [8]
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 0xFF, 
 0xFF, 
 0xFF, 
 0xFF, 
 0xFF, 
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 0x00, 
 BLE_Firmware_Version, 
 0x00 // Reserved        //		
};

In above buffer I reduce the Manufacture specific data type length from 0x17 to 0x10.

And check the advertising packet on NRF Connect App.

Code advertising but in Raw data it shows empty. No data is displayed

I attached the NRF connect snapshot also

Following is the advertising init function.

static void advertising_init(void)
{
    ret_code_t     err_code;
    uint8_t        adv_flags;
    ble_advertising_init_t init;

    memset(&init, 0, sizeof(init));

    adv_flags                             = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    init.advdata.name_type                = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance       = true;
    init.advdata.flags                    = adv_flags;
    init.advdata.uuids_complete.uuid_cnt  = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids   = m_adv_uuids;

    init.config.ble_adv_whitelist_enabled = false;
    init.config.ble_adv_fast_enabled      = true;
    init.config.ble_adv_fast_interval     = APP_ADV_FAST_INTERVAL;
    init.config.ble_adv_fast_timeout      = APP_ADV_FAST_TIMEOUT;
    init.config.ble_adv_slow_enabled      = false;

    init.evt_handler   = on_adv_evt;
    init.error_handler = ble_advertising_error_handler;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

sd_ble_gap_adv_data_set(BC_advertData, sizeof(BC_advertData), NULL, 0); 

this function is used for updating data for advertising.

Is length of advertising data packet depends on SDK_config file??

My code is based on peripheral blinky example. 

  • Hello,

    I guess you can check what sd_ble_gap_adv_data_set() returns, and I assume that it returns something not equal to 0 (== NRF_SUCCESS).

    I suggest you refer to one of the samples that actually use advertising, such as the SDK\examples\ble_peripheral\ble_app_uart example. This doesn't have manufacturer specific data, but if you try to add:

    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance = false;
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
        init.advdata.p_manuf_specific_data = p_my_manufacturer_specific_data;

    And this pointer needs to be a ble_advdata_manuf_data_t pointer. So initialize it something like this:

    ble_advdata_manuf_data_t * p_my_manufacturer_specific_data = 
        {
            .company_identifier = 0xFFFF
            .BC_advertData;
        }

    And always check the return values of the function calls where the function returns a value. If it doesn't return 0, check what that return value means.

    Best regards,

    Edvin

Related