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

Changing device name dynamically

Hi there,

I am using the nRF connect app on Android to see my dongle's name. I want the name to change every 5 seconds from one name to another. This is just for evaluation.

How can I do this? I am using SDK 15 with SD S140. I am using the LED button example.

A snippet of my code:

          BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
          sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)DEVICE_NAME_2, strlen(DEVICE_NAME_2));
          ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
          sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
          sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
          bsp_board_led_on(CONNECTED_LED);
          nrf_delay_ms(5000);
          BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
          sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)DEVICE_NAME, strlen(DEVICE_NAME));
          ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
          sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
          sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
          bsp_board_led_off(CONNECTED_LED);
          nrf_delay_ms(5000);

Related