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

configuring device name larger than 31 bytes in nRF52840 (SDK17)

Hello,

in our product we need to have the possibility to set name higher then 31 bytes.

We modify the code according the tick 

devzone.nordicsemi.com/.../sd_ble_cfg_set-for-ble_gap_cfg_device_name-returns-nrf_error_invalid_addr

in the following way but we get INVALID_STATE error:

static void gap_params_init(void)

{

    uint32_t                  err_code, ram_start;

    ble_gap_conn_params_t     gap_conn_params;

    ble_gap_conn_sec_mode_t   sec_mode;

    ble_cfg_t*                p_ble_cfg;

    ble_gap_cfg_device_name_t device_name = {0};

    uint16_t                  device_name_len;

 

    err_code = nrf_sdh_ble_app_ram_start_get(&ram_start);

    APP_ERROR_CHECK(err_code);

 

    //BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&sec_mode);

     device_name.vloc = BLE_GATTS_VLOC_USER;

    device_name.write_perm = sec_mode;

    device_name.p_value = m_actual_configuration.device_name;

    device_name.max_len = sizeof(m_actual_configuration.device_name);

    device_name.current_len = strlen(m_actual_configuration.device_name);

    p_ble_cfg = (ble_cfg_t*) &device_name;

    err_code = sd_ble_cfg_set(BLE_GAP_CFG_DEVICE_NAME, p_ble_cfg, ram_start);

    //device_name_len = strlen(m_actual_configuration.device_name);

    //err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) m_actual_configuration.device_name, device_name_len);

    APP_ERROR_CHECK(err_code);

 

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

    gap_conn_params.min_conn_interval = m_actual_configuration.min_connection_interval;

    gap_conn_params.max_conn_interval = m_actual_configuration.max_connection_interval;

    gap_conn_params.slave_latency     = m_actual_configuration.slave_latency;

    gap_conn_params.conn_sup_timeout  = m_actual_configuration.supervision_timeout;

 

    err_code = sd_ble_gap_ppcp_set(&gap_conn_params);

    APP_ERROR_CHECK(err_code);

}

The commented lines of code is code that works correctly but with the limitation in the device name length.

Thanks in advance for your help.

Elisa

Parents
  • Hi

    What size are you trying to set the device name to? According to the spec. the maximum device name length is 248. See BLE_GAP_DEVNAME_MAX_LEN in ble_gap.h of the SoftDevice you're using. However, I guess that your advertising_init() function uses the BLE_GAP_DEVNAME_DEFAULT_LEN of 31 as the maximum limit which is why you're seeing this error when trying to increase it beyond 31 bytes.

    Best regards,

    Simon

  • Hi Simon,

    thanks for your prompt reply.

    In the advertising we use the shortened name (8bytes) but we need a complete name length up to 40 bytes.
    Changing the BLE_GAP_DEVNAME_DEFAULT_LEN we get malfunction because, as explained in the blog, it's the space reserved for the name in the FLASH of SD.
    For what we understood in the ticket, to have a complete name higher than BLE_GAP_DEVNAME_DEFAULT_LEN (up to the BLE_GAP_DEVNAME_MAX_LEN value = 248) we need to allocate the device name in the RAM of the application like we did in the code I sent but it doesn't work.

    We are using SoftDevice version 7.0.1.

    Kind regards

    Elisa

Reply
  • Hi Simon,

    thanks for your prompt reply.

    In the advertising we use the shortened name (8bytes) but we need a complete name length up to 40 bytes.
    Changing the BLE_GAP_DEVNAME_DEFAULT_LEN we get malfunction because, as explained in the blog, it's the space reserved for the name in the FLASH of SD.
    For what we understood in the ticket, to have a complete name higher than BLE_GAP_DEVNAME_DEFAULT_LEN (up to the BLE_GAP_DEVNAME_MAX_LEN value = 248) we need to allocate the device name in the RAM of the application like we did in the code I sent but it doesn't work.

    We are using SoftDevice version 7.0.1.

    Kind regards

    Elisa

Children
No Data
Related