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

Related