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

  • 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

  • Hello again,

    Neeraj Dhekale said:
    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.

    Then the advertising packet is still too big to fit within the 31 byte limit.
    Currently you have flags (3 bytes), tx power (3 bytes), service data (16 bytes) and 2 bytes overhead for the name datafield. This leaves 7 bytes that you can use for the device name.
    How many bytes of the scan response packet are you using? Perhaps you could move the device name into the scan response as well, if there is more room left there. Alternatively you could try to move TX power to the scan response, to free up 3 additional bytes in the advertising data payload.

    Best regards,
    Karl

Reply
  • Hello again,

    Neeraj Dhekale said:
    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.

    Then the advertising packet is still too big to fit within the 31 byte limit.
    Currently you have flags (3 bytes), tx power (3 bytes), service data (16 bytes) and 2 bytes overhead for the name datafield. This leaves 7 bytes that you can use for the device name.
    How many bytes of the scan response packet are you using? Perhaps you could move the device name into the scan response as well, if there is more room left there. Alternatively you could try to move TX power to the scan response, to free up 3 additional bytes in the advertising data payload.

    Best regards,
    Karl

Children
  • Hello Karl Ylvisaker,

    I moved my GAP service data (which was in advdata in the above example) to scan response and then it works. Now it is getting displayed full name as mentioned above.

    Here is updated advertising_init() function.

    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.srdata.p_tx_power_level = &BT_TX_POWER;
        init.srdata.p_service_data_array =&obj;
        init.srdata.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.");
    }

    Please check and correct me if I am wrong or the way I did.

    Thanks and Regards,

    Neeraj

  • Hello Neeraj,

    Now you have moved both the UUID list and the service data into the scan response, which are the two big datafields in your advertising. Keep in mind that I do not know the size of the UUID data, but since the SoftDevice would complain if it did not fit into the scan response then I would think that this is all right!
    At least I do not see any issue in the code snippet you have provided.
    I would recommend that you clean up the code a little, and remove all commented lines to increase readability and maintainability.

    Are you not going to be using an advertising event handler in your application?

    Best regards,
    Karl

  • Hello Karl Ylvisaker,

    Now you have moved both the UUID list and the service data into the scan response

    Corrected. Moved UUID to advdata and kept service data into the scan response.

    At least I do not see any issue in the code snippet you have provided.

    Okay, Noted.

    I would recommend that you clean up the code a little, and remove all commented lines to increase readability and maintainability.

    Corrected and thanks for this. I will keep it in mind.

    Are you not going to be using an advertising event handler in your application?

    Currently Not needed. Maybe I will use it in the future.

    Thanks and regards,

    Neeraj Dhekale

Related