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

For nrf52840 need to be change the BLE device name and set the Password example code!!

Dear !!

Good day!!

I want to change the device name using command from mobile along wither after setting the device name i want update the Password, so can you share any example code.

Regards

Chandru

Parents
  • Dear sir, 

    Device name set code is below, and i'm able to change the device name but once reset or OF/ON conditions the existing name is coming, what to to??

    static void setDeviceName(uint8_t *device_name)
    {
    ble_gap_conn_sec_mode_t sec_mode;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    /* Change device name */
    uint32_t err_code = sd_ble_gap_device_name_set(&sec_mode,
    (const uint8_t *)device_name,
    strlen(device_name));
    APP_ERROR_CHECK(err_code);

    /* Store Current connection state od adv lib */
    uint16_t m_adv_current_slave_link_conn_handle_saved = m_advertising.current_slave_link_conn_handle;

    /* Re-initialize advertising module */
    advertising_init();

    /* Re-store Current connection state lib */
    m_advertising.current_slave_link_conn_handle = m_adv_current_slave_link_conn_handle_saved;

    printf("Name has been set %s \n",device_name);
    nrf_gpio_pin_clear(GREEN_LED);
    }

    Thanks & Regards

    Chandru.A

Reply
  • Dear sir, 

    Device name set code is below, and i'm able to change the device name but once reset or OF/ON conditions the existing name is coming, what to to??

    static void setDeviceName(uint8_t *device_name)
    {
    ble_gap_conn_sec_mode_t sec_mode;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    /* Change device name */
    uint32_t err_code = sd_ble_gap_device_name_set(&sec_mode,
    (const uint8_t *)device_name,
    strlen(device_name));
    APP_ERROR_CHECK(err_code);

    /* Store Current connection state od adv lib */
    uint16_t m_adv_current_slave_link_conn_handle_saved = m_advertising.current_slave_link_conn_handle;

    /* Re-initialize advertising module */
    advertising_init();

    /* Re-store Current connection state lib */
    m_advertising.current_slave_link_conn_handle = m_adv_current_slave_link_conn_handle_saved;

    printf("Name has been set %s \n",device_name);
    nrf_gpio_pin_clear(GREEN_LED);
    }

    Thanks & Regards

    Chandru.A

Children
Related