This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Softdevice - The increasing size of advertisement causes crop in advertisement name

Hello,

I am using nRF 52840 DK board and using nRF52SDK17.0.2. I am trying to advertise data in GAP with the name "IG_Last4CharMAC_RFL" for example "IG_4DA8_RFL" but whenever I increase below obj.data.size =2; to obj.data.size =12; it is getting increased, but advertise name is getting a crop and looks like "IG_". I have tried to find an advertising buffer in sdk_config.h file but I did not find anything related to it. What shall I do to avoid this issue?

 ret_code_t             err_code;
 ble_advertising_init_t init;

ble_advdata_service_data_t obj;
obj.service_uuid = BLE_UUID_TX_POWER_SERVICE;

obj.data.p_data = sensorData;
obj.data.size =12;
    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_GENERAL_DISC_MODE; //displayed in raw as type 0x01
    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.advdata.p_manuf_specific_data = 0xFF;


init.advdata.p_tx_power_level = &BT_TX_POWER;
    init.advdata.p_service_data_array =&obj;
    init.advdata.service_data_count=1;

      //init.config.ble_adv_primary_phy      = BLE_GAP_PHY_1MBPS;
    //init.config.ble_adv_secondary_phy    = BLE_GAP_PHY_2MBPS;
    //init.config.ble_adv_extended_enabled = true;

    //init.config.ble_adv_directed_high_duty_enabled  = true;
    init.config.ble_adv_fast_enabled  = true;
    init.config.ble_adv_fast_interval = BT_GAP_INT_MAX;
    init.config.ble_adv_slow_interval = BT_GAP_INT_MIN;
    init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    init.config.ble_adv_slow_timeout  = APP_ADV_DURATION;

   // init.evt_handler = on_adv_evt;
    err_code = ble_advertising_init(&m_advertising, &init);
  //  APP_ERROR_CHECK(err_code);
     NRF_LOG_INFO("ble_advertising_init %d",err_code);
  sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, BT_TX_POWER);
    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    NRF_LOG_INFO("advertising_init done.");

I am attaching my sdk_config.h file. Please have a look and let me know or is there an alternate solution to this?

6622.sdk_config.h

Please help. Thanks in advance.

Thanks and regards,

Neeraj Dhekale

Parents
  • Hello,

    Legacy advertising has a hard 31 byte limit, meaning that the entire data payload of the advertising must be less than 31 bytes. Each new datafield (such as device name, flags, manufacturer specific data) also requires 2 bytes of overhead.
    The SoftDevice will remove characters from the device name if it is not room for the entire name.
    I notice that you are not setting up a scan response in your code - could this be an option for you, to move the name into the scan response instead?
    The scan response can be 31 bytes as well, effectively doubling the possible advertising data.

    I also notice that you have commented out the APP_ERROR_CHECK for the ble_advertising_init, and that there is no APP_ERROR_CHECK for your TX_POWER set function - I would strongly advice that you add APP_ERROR_CHECKS for both of these, so that you may know if the program encounters an error here.

    Best regards,
    Karl

Reply
  • Hello,

    Legacy advertising has a hard 31 byte limit, meaning that the entire data payload of the advertising must be less than 31 bytes. Each new datafield (such as device name, flags, manufacturer specific data) also requires 2 bytes of overhead.
    The SoftDevice will remove characters from the device name if it is not room for the entire name.
    I notice that you are not setting up a scan response in your code - could this be an option for you, to move the name into the scan response instead?
    The scan response can be 31 bytes as well, effectively doubling the possible advertising data.

    I also notice that you have commented out the APP_ERROR_CHECK for the ble_advertising_init, and that there is no APP_ERROR_CHECK for your TX_POWER set function - I would strongly advice that you add APP_ERROR_CHECKS for both of these, so that you may know if the program encounters an error here.

    Best regards,
    Karl

Children
  • Hello Karl Ylvisaker,

    could this be an option for you, to move the name into the scan response instead?

    I will try this and will update you.

    I also notice that you have commented out the APP_ERROR_CHECK for the ble_advertising_init

    corrected.

    and that there is no APP_ERROR_CHECK for your TX_POWER set function - I would strongly advice that you add APP_ERROR_CHECKS for both of these, so that you may know if the program encounters an error here.

    Corrected. Thank you so much for this.

    Thanks and regards,

    Neeraj Dhekale

  • Hello Neeraj Dhekale,

    Great, I am glad to hear that you have added the checks back in.
    I look forward to hearing your update on the use of scan response!

    Best regards,
    Karl

  • I have tried to add below line to advertising_init(). But it doesnot work. it is still showing name as "IG_" in nRF connect app.

    memset(&scanrsp, 0, sizeof(scanrsp));
        scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        scanrsp.uuids_complete.p_uuids  = m_adv_uuids;

    only adding above line will work?

    Thanks and regards,

    Neeraj Dhekale

  • Neeraj Dhekale said:
    only adding above line will work?

    No, the scan response data should be put in the same ble_advertising_init_t structure as the advertising data.
    You can see an example of how this is done in the ble_app_uart peripheral example in the nRF5 SDK.

    Best regards,
    Karl

  • Hello Karl Ylvisaker,

    Thanks for confirming. I have tried to implement scan response by checking int ble_app_uart. And now 1st  7 characters are getting displayed for example "IG_4D25" still 3 more characters are yet to be displayed.

    My updated advertising_init() function is below:

    void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;
    uint32_t err;
    
    ble_advdata_service_data_t obj;
    obj.service_uuid = BLE_UUID_TX_POWER_SERVICE;
    
    obj.data.p_data = loadcellData;
    obj.data.size =12;
        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_GENERAL_DISC_MODE; //displayed in raw as type 0x01
       // 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.advdata.p_manuf_specific_data = 0xFF;
    
        init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.srdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.advdata.p_tx_power_level = &BT_TX_POWER;
        init.advdata.p_service_data_array =&obj;
        init.advdata.service_data_count=1;
    
          //init.config.ble_adv_primary_phy      = BLE_GAP_PHY_1MBPS;
        //init.config.ble_adv_secondary_phy    = BLE_GAP_PHY_2MBPS;
        //init.config.ble_adv_extended_enabled = true;
    
        //init.config.ble_adv_directed_high_duty_enabled  = true;
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = BT_GAP_INT_MAX;
        init.config.ble_adv_slow_interval = BT_GAP_INT_MIN;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
        init.config.ble_adv_slow_timeout  = APP_ADV_DURATION;
    
       // init.evt_handler = on_adv_evt;
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
        NRF_LOG_INFO("ble_advertising_init %d",err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
        NRF_LOG_INFO("advertising_init done.");
    }

    Thanks and regards,

    Neeraj Dhekale

Related