nRF5 SDK for Thread and Zigbee v2.0.0
BLE and Thread Template Example

Table of Contents

The Switched BLE-Thread Template example demonstrates the usage of the switched multiprotocol method. This example is a merge of a simplified version of BLE Peripheral Template and Thread CLI Example applications.

The nRF52840 device can operate in the following modes:

Description

By default, the application starts in the BLE Peripheral mode. To select a mode, press the buttons on the nRF52840 Development Kit.

When you press BSP_BUTTON_2, application disables the BLE stack (SoftDevice) and enables the Thread stack, which is indicated by BSP_LED_1. The device starts Thread attachment procedure.

When you press BSP_BUTTON_3, the application disables the Thread stack and reinitializes the BLE stack (SoftDevice), which is indicated by BSP_LED_1. The device starts to advertise.

LED assignments:

Button assignments:

Setup

You can find the source code and the makefile in the following folder: <InstallFolder>\examples\multiprotocol\ble_thread\ble_thread_swi_template

Testing

  1. Prepare at least one nRF52840 Preview Development Kit and an Android smartphone.
  2. On the smartphone, install nRF Connect for Mobile.
  3. Compile and program the SoftDevice and the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
  4. Connect to the device from nRF Connect (the device is advertising as Nordic_Template). Observe that the BSP_INDICATE_CONNECTED state is indicated.
  5. Disconnect the device in nRF Connect and observe that the BSP_INDICATE_ADVERTISING state is indicated.
  6. Switch from BLE mode to Thread mode by pushing BSP_BUTTON_2.
  7. Observe that BSP_LED_1 is lit, and so is BSP_LED_0 after the node is attached to the Thread network.
  8. Connect to the board through UART. The application uses the following UART settings:
    • Baud rate: 115200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
    Refer to OpenThread CLI reference for complete reference of the OpenThread Command Line Interface.
  9. Run the state command to check the state of the device in the Thread network:
    > state
    leader
    Done
    Note
    If there are any other Thread devices using the same channel and PANID, the observed state can be router or child.
  10. Switch from Thread mode to BLE mode again by pushing BSP_BUTTON_3.

Documentation feedback | Developer Zone | Subscribe | Updated