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

change the device name while connected

Hi,

I am using 

  • nRF52840
  • SDK 15.3.0
  • Keil IDE
  • The soft device is S140 
  • JLinkRTTViewer for debug

I changed the device name while not connected.

but, The device made a connection with the smartphone.

and I tried to change the device name using the same function as above.

a fatal error occurs when executing the function.

please advice

-----------

void re_device_name(void)
{
uint32_t err_code;
ble_advertising_t * const p_advertising = NULL;

*p_advertising = m_advertising;
(void) sd_ble_gap_adv_stop(p_advertising->adv_handle);
bluetooth_update_name(m_system_data.equip_name);

advertising_init();
err_code = ble_advertising_restart_without_whitelist(&m_advertising);
}

Parents Reply Children
  • I assume that is is the sd_ble_gap_device_name_set() that return NRF_ERROR_DATA_SIZE. Not quite sure what may trigger that, but likely a parameter in sd_ble_gap_device_name_get() is wrong. You an refer to gap_params_init() on example.

    Kenneth

  • Hi, Kenneth

    Thanks for the answer.

    Changing the device name works well when the smartphone is not connected.

    I have attached the gap_params_init() function.

    void gap_params_init(void)
    {
        ret_code_t              err_code;
        ble_gap_conn_params_t   gap_conn_params;
        ble_gap_conn_sec_mode_t sec_mode;
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
    
    	get_ble_device_name();	
        err_code = sd_ble_gap_device_name_set(&sec_mode,
    //                                          (const uint8_t *) device_name,
                                               device_name, strlen( (char const *)device_name));
    	NRF_LOG_INFO("device_name= 0x%x", strlen( (char const *)device_name))
    										  
        APP_ERROR_CHECK(err_code);
    
        memset(&gap_conn_params, 0, sizeof(gap_conn_params));
    
        gap_conn_params.min_conn_interval = m_scan.conn_params.min_conn_interval;
        gap_conn_params.max_conn_interval = m_scan.conn_params.max_conn_interval;
        gap_conn_params.slave_latency     = m_scan.conn_params.slave_latency;
        gap_conn_params.conn_sup_timeout  = m_scan.conn_params.conn_sup_timeout;
    
        err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
        APP_ERROR_CHECK(err_code);
    }

    Alex

  • I suggest you share a simplified example I can unzip to the RF5 SDK v15.3 and run on an nRF52-DK to recreate the issue.

    Best regards,
    Kenneth

Related