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

Change Bluetooth Device Name From iOS

Hi ,

I am using nRF6.0.0, SoftDevice 7.0, for nRF 6310 hardware. I am trying to develop a ble keyboard app with the help of Ble Keyboard Sample we have in the SDK. As you might be aware that the device name is set when it is booted (e.g Nordic_Keyboard).

Is there any way I can change the name of the device from iOS once it is connected or while booting without flashing the hardware(through config file or something).

Kind Regards, Ven

  • Hi,

    You can set the device name to be writable remotely by a peer. Simply find where sd_ble_gap_device_name_set() is called and make sure the p_write_perm is pointing to a ble_gap_conn_sec_mode_t that has the proper permission levels. There are macros available like BLE_GAP_CONN_SEC_MODE_SET_OPEN that can be used to set the conn_sec_mode to more human-readable properties. The default setting is to not allow any writes, i.e. BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS (security mode 0, level 0). You can also require encryption (with or without MITM protection) to write to the device name.

    When this permission is set, the peer can write to the device name remotely. This will however be lost when the device goes into system off, so I would recommend saving the device name to e.g flash (using pstorage). That allows you to check flash during startup and pull a device name from there, if present.

    Ex:

    #define STR_DEVICE_NAME "MY DEVICE NAME"
    ble_gap_conn_sec_mode_t security;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&security);
    sd_ble_gap_device_name_set(&security, STR_DEVICE_NAME, (uint16_t)strlen(STR_DEVICE_NAME)))
    

    A second alternative is to set something in the UICR during mass production. The device can then pick up a name from there, without having to rely on a peer to change it.

  • Is it possible send me an example if you have any?

  • Sure, just find where the device name is set. This is where sd_ble_gap_device_name_set() is called, then replace the code with the code snippet I added to the original answer.

  • Thank you Ulrich. The problem I am facing is in using pstorage. I have seen some examples where pstorage is used to write to flash but I am struggling understand the following.

    1. How do I retrieve the device name from flash after restart(i.e how do I know the exact flash location)
    2. I have read someone saying we need to change the flash address settings in Keil.. How to determine which values to increase and what would be the size.

    Can example with pstorage with all the above queries in mind would be grateful.

Related