nRF5 SDK v11.0.0
Example application
This information applies to the following SoftDevices: S130, S132, S332

To show how to add BLE DFU Service support to an application, the SDK contains a version of the Heart Rate Application that includes DFU support. This example illustrates how a standard application can be extended so that you can easily update the device firmware at any time, just by connecting to the application.

You can find the source code and project file of the example in the following folder: <InstallFolder>\examples\ble_peripheral\ble_app_hrs

When testing the example, you can choose to use bonding to share encryption keys between the application and the bootloader. If you use bonding, the link between the DFU target and the DFU controller will be re-established with encryption when the device restarts in bootloader mode. See Sharing bonding information for more information.

Testing the example

Test the Heart Rate Application with BLE DFU Service support with the Master Control Panel by performing the following steps:

  1. Program the DFU bootloader.
  2. Compile the application and perform a Device Firmware Update to program it. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. Connect to the device from Master Control Panel, and optionally bond to it.
  4. Perform service discovery. The device is advertising as "Nordic_HRM". Observe that the BSP_INDICATE_CONNECTED state is indicated.
  5. Click "Enable services".
  6. Click "DFU" to start the Device Firmware Update (see step 5 in Updating the device firmware).

Testing the example manually (with bonding)

Test the Heart Rate Application with BLE DFU Service support using bonding with the Master Control Panel by performing the following steps:

  1. Program the DFU bootloader.
  2. Compile the application and perform a Device Firmware Update to program it. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. Connect to the device from Master Control Panel, then bond to it.
  4. Perform service discovery. The device is advertising as "Nordic_HRM". Observe that the BSP_INDICATE_CONNECTED state is indicated.
  5. Write the value "0200" to the Service Changed characteristic to enable the Service Changed indication when the GATT Server Attribute Table changes.
  6. Write the value "0100" to the CCCD for the DFU Control Point characteristic or click Enable services to enable DFU notifications.
  7. Write the command to start a DFU procedure to the DFU Control Point:
    • "01-01" if you want to update the SoftDevice
    • "01-02" if you want to update the bootloader
    • "01-03" if you want to update the SoftDevice and bootloader
    • "01-04" if you want to update the application
  8. Observe that the connection to the device is lost. The message "SERVER: Received Link Loss" is displayed in the log window.
  9. The device is now performing directed advertising to the bonded peer. When the connection is established, a Service Changed indication is received and displayed in the Master Control Panel.
  10. Perform a Device Firmware Update. You do not need to connect to the device again, because you are already connected.

Testing the example manually (without bonding)

Test the Heart Rate Application with BLE DFU Service support not using bonding with the Master Control Panel by performing the following steps:

  1. Program the DFU bootloader.
  2. Compile the application and perform a Device Firmware Update to program it. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. Connect to the device from Master Control Panel.
  4. Perform service discovery. The device is advertising as "Nordic_HRM". Observe that the BSP_INDICATE_CONNECTED state is indicated.
  5. Write the value "0100" to the CCCD for the DFU Control Point characteristic or click Enable services to enable DFU notifications.
  6. Write the command to start a DFU procedure to the DFU Control Point:
    • "01-01" if you want to update the SoftDevice
    • "01-02" if you want to update the bootloader
    • "01-03" if you want to update the SoftDevice and bootloader
    • "01-04" if you want to update the application
  7. Observe that the connection to the device is lost. The message "SERVER: Received Link Loss" is displayed in the log window.
  8. Click "Back" in the Master Control Panel to see an overview of the discovered devices.
  9. Clear the discovered devices and click "Start discovery".
  10. Verify that the device is now advertising as "DfuTarg".
  11. Perform a Device Firmware Update.

Documentation feedback | Developer Zone | Updated