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

Device name advertises for short name even after setting for full name.

Hello,

I have set the device advertising as follows: 

static void advertising_init(void)
{
    ret_code_t           err_code;
    ble_advdata_t        advdata;
    ble_advdata_t        srdata;
    ble_gap_adv_params_t adv_params;


    ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};

    // Build and set advertising data.
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = true;
    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;


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

    err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
    #ifdef DEBUG
     printf("ble_advdata_encode%d\n",err_code);
    #endif
    APP_ERROR_CHECK(err_code);

    err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
    #ifdef DEBUG
     printf("ble_advdata_encodesrdata%d\n",err_code);
    #endif
    APP_ERROR_CHECK(err_code);

    // Start advertising.
    memset(&adv_params, 0, sizeof(adv_params));
    adv_params.p_peer_addr   = NULL;
    adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
    adv_params.interval      = APP_ADV_INTERVAL;

    adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
    adv_params.duration        = APP_ADV_DURATION;
    adv_params.primary_phy     = BLE_GAP_PHY_1MBPS;

    err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
    #ifdef DEBUG
     printf("sd_ble_gap_adv_set_configure%d\n",err_code);
    #endif
    APP_ERROR_CHECK(err_code);
}

Advertising name is getting broadcasted with a full name until it gets changed and to 4 letters device name. In my application, there is a need for changing the advertising name for 5 min duration and that name is of 4 characters only. That gets advertised successfully. But the problem arises after again changing to the first advertising name, which has more than 4 letters. It does not get advertised with full name only the first 4 characteristics get advertised. 

Advertising init function is used every time I changed the advertising name which has full name advertising settings. My first name is "LED_BUTTON"(10 characters) and the second name is "TEST"(4 characters). I want to switch the first name with 2nd for 5 min and again to first. Below code shows how i have changed name:

ret_code_t err_code = sd_ble_gap_adv_stop(m_adv_handle);
        APP_ERROR_CHECK(err_code);
        err_code = sd_ble_gap_device_name_set(&sec_mode,(const uint8_t *)DEVICE_NAME,strlen(DEVICE_NAME));
        APP_ERROR_CHECK(err_code);
        advertising_init();
        err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
        APP_ERROR_CHECK(err_code);

What should i do for advertising with full name after changing advertising name dynamucally in code for 5 min. 

Parents
  • Hi

    Do you set the name type as SHORT_NAME when you change the name to TEST? If so, can you try keeping it as FULL_NAME to see if that lets you get the full first name again? Does the advertisement itself change when it's called LED_BUTTON the first time versus after the name has changed once and twice? It might be that the advertising packet is filled with something else the third time around, not leaving any space for the full name to be advertised.

    Best regards,

    Simon

  • Do you set the name type as SHORT_NAME when you change the name to TEST?

    NO, I am using the same advertising_init(); function for setting advertising parameters. 

    t might be that the advertising packet is filled with something else the third time around, not leaving any space for the full name to be advertised.

    How to know an advertising packet is getting filled with some data that no space for advertising full name.?

Reply Children
No Data
Related