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

Why is my device name being truncated?

Using SDK 14.0.0 with SD 132 v5, the device name I'm advertising with here is "000000DK". But the advertising module is truncating it to "0000". It will do this if I have too much advertising data, but I don't. I should have 31 bytes and that should be fine. It was fine with SDK 12.1 and an earlier SD version.

image description

I've read this post on the same subject, but it doesn't explain this:

devzone.nordicsemi.com/.../

It looks like it's the appearance that's overflowing me. This was never a problem before and if I now omit any call to sd_ble_gap_appearance_set(), I get 0x0000 as the appearance field, whereas I think I used to get no appearance field at all. How do I remove the appearance and get the same behaviour I used to have with the earlier SDK/SD?

Parents
  • On the picture you have (beside last Device Name AD) three AD objects. They come in Length-Tag-Value form where length counts also Tag. So by simple math 3+2+17+3(length bytes) = 25 bytes which leaves just 6 for whole Device Name AD element to be 31 in total. When you cut Length and Tag you have your 4 bytes so module is having this right. The question is which AD element has changed since previous version (and then by looking to changes in SDK code you should easily spot why and how to fix it).

  • Here you go, \components\ble\common\ble_advdata.h file line #148 inside struct ble_advdata_t:

    bool include_appearance; /**< Determines if Appearance shall be included. */
    
  • I wrote function for advertising like that;

    static void advertising_init(void)
    {
        ret_code_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_GENERAL_DISC_MODE;
        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_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
    
        init.evt_handler = on_adv_evt;
    
        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);
    }

    But still I can not see full device name. When include_appearance is true I can see 4 charecter, When include_appearance is false I can see 8 charecter. I understand the data length calculation but I want to see full device name. So, Can I make the length more than 31 bytes? Or is there another way to see full device name?

  • 31 bytes is maximum. If you want to have a longer device name you need to remove something else, UUID for example.

Reply Children
Related