|
| 1 | +.. _ble_gap_device_name_sample: |
| 2 | + |
| 3 | +Bluetooth: Generic Access Profile Device Name |
| 4 | +############################################# |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The GAP Device Name sample demonstrates how to read and write the BLE GAP Device Name characteristic using |BMlong|. |
| 11 | +A connected peer can change the device name over BLE. The new name takes effect immediately, persists across disconnects, and survives power cycles. |
| 12 | + |
| 13 | +Requirements |
| 14 | +************ |
| 15 | + |
| 16 | +The sample supports the following development kits: |
| 17 | + |
| 18 | +.. tabs:: |
| 19 | + |
| 20 | + .. group-tab:: Simple board variants |
| 21 | + |
| 22 | + The following board variants do **not** have DFU capabilities: |
| 23 | + |
| 24 | + .. list-table:: |
| 25 | + :header-rows: 1 |
| 26 | + |
| 27 | + * - Hardware platform |
| 28 | + - PCA |
| 29 | + - SoftDevice |
| 30 | + - Board target |
| 31 | + * - `nRF54L15 DK`_ |
| 32 | + - PCA10156 |
| 33 | + - S115 |
| 34 | + - bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice |
| 35 | + * - `nRF54L15 DK`_ (emulating nRF54L10) |
| 36 | + - PCA10156 |
| 37 | + - S115 |
| 38 | + - bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice |
| 39 | + * - `nRF54L15 DK`_ (emulating nRF54L05) |
| 40 | + - PCA10156 |
| 41 | + - S115 |
| 42 | + - bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice |
| 43 | + * - `nRF54LM20 DK`_ |
| 44 | + - PCA10184 |
| 45 | + - S115 |
| 46 | + - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice |
| 47 | + * - nRF54LS05 DK |
| 48 | + - PCA10214 |
| 49 | + - S115 |
| 50 | + - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice |
| 51 | + * - `nRF54LV10 DK`_ |
| 52 | + - PCA10188 |
| 53 | + - S115 |
| 54 | + - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice |
| 55 | + * - `nRF54L15 DK`_ |
| 56 | + - PCA10156 |
| 57 | + - S145 |
| 58 | + - bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice |
| 59 | + * - `nRF54L15 DK`_ (emulating nRF54L10) |
| 60 | + - PCA10156 |
| 61 | + - S145 |
| 62 | + - bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice |
| 63 | + * - `nRF54L15 DK`_ (emulating nRF54L05) |
| 64 | + - PCA10156 |
| 65 | + - S145 |
| 66 | + - bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice |
| 67 | + * - `nRF54LM20 DK`_ |
| 68 | + - PCA10184 |
| 69 | + - S145 |
| 70 | + - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice |
| 71 | + * - nRF54LS05 DK |
| 72 | + - PCA10214 |
| 73 | + - S145 |
| 74 | + - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice |
| 75 | + * - `nRF54LV10 DK`_ |
| 76 | + - PCA10188 |
| 77 | + - S145 |
| 78 | + - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice |
| 79 | + |
| 80 | + .. group-tab:: MCUboot board variants |
| 81 | + |
| 82 | + The following board variants have DFU capabilities: |
| 83 | + |
| 84 | + .. list-table:: |
| 85 | + :header-rows: 1 |
| 86 | + |
| 87 | + * - Hardware platform |
| 88 | + - PCA |
| 89 | + - SoftDevice |
| 90 | + - Board target |
| 91 | + * - `nRF54L15 DK`_ |
| 92 | + - PCA10156 |
| 93 | + - S115 |
| 94 | + - bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice/mcuboot |
| 95 | + * - `nRF54L15 DK`_ (emulating nRF54L10) |
| 96 | + - PCA10156 |
| 97 | + - S115 |
| 98 | + - bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice/mcuboot |
| 99 | + * - `nRF54L15 DK`_ (emulating nRF54L05) |
| 100 | + - PCA10156 |
| 101 | + - S115 |
| 102 | + - bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice/mcuboot |
| 103 | + * - `nRF54LM20 DK`_ |
| 104 | + - PCA10184 |
| 105 | + - S115 |
| 106 | + - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice/mcuboot |
| 107 | + * - nRF54LS05 DK |
| 108 | + - PCA10214 |
| 109 | + - S115 |
| 110 | + - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice/mcuboot |
| 111 | + * - `nRF54LV10 DK`_ |
| 112 | + - PCA10188 |
| 113 | + - S115 |
| 114 | + - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice/mcuboot |
| 115 | + * - `nRF54L15 DK`_ |
| 116 | + - PCA10156 |
| 117 | + - S145 |
| 118 | + - bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice/mcuboot |
| 119 | + * - `nRF54L15 DK`_ (emulating nRF54L10) |
| 120 | + - PCA10156 |
| 121 | + - S145 |
| 122 | + - bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice/mcuboot |
| 123 | + * - `nRF54L15 DK`_ (emulating nRF54L05) |
| 124 | + - PCA10156 |
| 125 | + - S145 |
| 126 | + - bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcuboot |
| 127 | + * - `nRF54LM20 DK`_ |
| 128 | + - PCA10184 |
| 129 | + - S145 |
| 130 | + - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice/mcuboot |
| 131 | + * - nRF54LS05 DK |
| 132 | + - PCA10214 |
| 133 | + - S145 |
| 134 | + - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice/mcuboot |
| 135 | + * - `nRF54LV10 DK`_ |
| 136 | + - PCA10188 |
| 137 | + - S145 |
| 138 | + - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice/mcuboot |
| 139 | + |
| 140 | +Overview |
| 141 | +******** |
| 142 | + |
| 143 | +The sample advertises with a configurable device name and allows any connected peer to write a new name to the GAP Device Name characteristic (UUID 0x2A00). |
| 144 | +When a new name is written: |
| 145 | +* The SoftDevice GAP name is updated immediately. |
| 146 | +* The advertising data is refreshed so scanners see the new name after disconnect. |
| 147 | +* The name is saved to flash (BM ZMS) so it persists across reboots. |
| 148 | + |
| 149 | +On boot, the sample loads the previously saved name from storage. |
| 150 | +If none exists, it falls back to the default configured via :kconfig:option:`CONFIG_SAMPLE_BLE_DEVICE_NAME`. |
| 151 | + |
| 152 | +User interface |
| 153 | +************** |
| 154 | + |
| 155 | +LED 0: |
| 156 | + Lit when the device is initialized. |
| 157 | + |
| 158 | +LED 1: |
| 159 | + Lit when a device is connected. |
| 160 | + |
| 161 | +Building and running |
| 162 | +******************** |
| 163 | + |
| 164 | +This sample can be found under :file:`samples/bluetooth/ble_gap_device_name/` in the |BMshort| folder structure. |
| 165 | + |
| 166 | +For details on how to create, configure, and program a sample, see :ref:`getting_started_with_the_samples`. |
| 167 | + |
| 168 | +Testing |
| 169 | +======= |
| 170 | + |
| 171 | +1. Compile and program the application. |
| 172 | +#. Connect the device to the computer. |
| 173 | +#. Connect to the kit with a terminal emulator (for example, the `Serial Terminal app`_). |
| 174 | +#. Reset the kit. |
| 175 | +#. Observe that ``Advertising as nRF_BM_GAP_DN`` is printed in the terminal. |
| 176 | + You can configure this default name using the :kconfig:option:`CONFIG_SAMPLE_BLE_DEVICE_NAME` Kconfig option. |
| 177 | +#. Open the `nRF Connect`_ mobile app and connect to the device. |
| 178 | +#. In the GAP service, find the **Device Name** characteristic (UUID 0x2A00). |
| 179 | +#. Read the current name to verify it matches the advertised name. |
| 180 | +#. Write a new name (for example, ``MyDevice``). |
| 181 | +#. Observe that the terminal prints:: |
| 182 | + |
| 183 | + Device name updated (8 bytes) |
| 184 | + New name |
| 185 | + 4d 79 44 65 76 69 63 65 |MyDevice |
| 186 | + |
| 187 | +#. Observe that ``Device name persisted to storage`` is printed shortly after. |
| 188 | +#. Disconnect from the device. |
| 189 | +#. Observe that the device now advertises with the new name ``MyDevice``. |
| 190 | +#. Reset the kit and observe that the saved name is loaded from storage and used for advertising. |
0 commit comments