This information applies to the following SoCs: nRF52833 and nRF52840.
This example requires the following SoftDevice: S140
Important: Before you run this example, make sure to program the SoftDevice.
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.
For more information about multiprotocol support, see Multiprotocol support with BLE/Bluetooth.
The nRF52 device can operate in the following modes:
- BLE Peripheral mode – sends connectable advertisements.
- Thread FTD mode – provides OpenThread’s built-in command line interface (CLI), and automatically attaches to the Thread network.
Description
By default, the application starts in the BLE Peripheral mode. To select a mode, press the buttons on the nRF52 Development Kit (see thread_multi_switched_template_example_setup_button).
Setup
You can find the source code and the makefile in the following folder: <InstallFolder>\examples\multiprotocol\ble_thread\ble_thread_swi_template
LED assignments
The example uses LED assignments as described in Thread BSP LED and button reference for the following LEDs:
- LED1 – Used to indicate the network connection state (over BLE and Thread).
The LED assignments are different for the following LEDs:
- LED2 – Used to indicate the active network stack:
- Disabled - BLE.
- Solid - Thread.
Button assignments
The following buttons reserved for user application purposes are assigned in this example:
- Button 3: Switch protocol from BLE to Thread.
- The application disables the BLE stack (SoftDevice) and enables the Thread stack, which is indicated by LED2. The device starts Thread attachment procedure.
- Button 4: Switch protocol from Thread to BLE.
- The application disables the Thread stack and reinitializes the BLE stack (SoftDevice), which is indicated by LED2. The device starts to advertise.
Testing
The following testing procedure uses the nRF52840 device.
- Prepare at least one nRF52840 Preview Development Kit and an Android smartphone.
- On the smartphone, install nRF Connect for Mobile.
- Compile and program the SoftDevice and the application. Observe that the BSP_INDICATE_ADVERTISING state is indicated.
- Connect to the device from nRF Connect (the device is advertising as Nordic_Template). Observe that the BSP_INDICATE_CONNECTED state is indicated.
- Disconnect the device in nRF Connect and observe that the BSP_INDICATE_ADVERTISING state is indicated.
- Switch from BLE mode to Thread mode by pressing Button 3.
- Observe that LED2 lights up, and so does LED1 after the node is attached to the Thread network.
- 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.
- Run the
state
command to check the state of the device in the Thread network: - Note
- If there are any other Thread devices using the same channel and PANID, the observed state can be
router
or child
.
- Switch from Thread mode to BLE mode again by pressing Button 4.