This information applies to the nRF52840 SoC only.
This example requires the following SoftDevice: S140
Important: Before you run this example, make sure to program the SoftDevice.
- Warning
- There is an issue in the nRF5 SDK for Thread and Zigbee v4.1.0 that causes higher-than-usual sleep power consumption for all multiprotocol examples when using nRF52840. See workaround on DevZone.
The BLE Proximity and Thread CoAP Server Example example is provided in two configurations:
- UART configuration that uses UART communication and SEGGER J-Link as a UART-USB converter
- USB configuration that uses the USB peripheral available in nRF52840 and communicates as a native USB CDC device.
For more information about multiprotocol support, see Multiprotocol support with BLE/Bluetooth.
If native USB CDC connectivity is used on Windows XP/7 hosts, you must manually install the nordic_cdc_acm.inf
driver located at <InstallFolder>\examples\usb_drivers
. Hosts running on Windows 8 (and later) will automatically pick the correct driver (usbser.sys).
This BLE-Thread dynamic multiprotocol example requires you to run on the second board any complementary example that contains Thread CoAP Server functionality, for example:
This example application is based on the Proximity Application example available in nRF5 SDK. It has been extended to support dynamic switching between two connection modes, BLE and Thread, at the same time (concurrently). Thread operates on the 802.15.4 radio during Bluetooth low energy radio's inactive time (using Timeslot API). Depending on the Bluetooth low energy connection interval, nRF52840 SoC can spend up to 99% of the radio time on Thread protocol.
This example also supports the Thread CoAP Server role as described in Simple CoAP Server example.
The application works similarly to ble_app_proximity
, using BLE Proximity and BLE Find Me Profiles. When the device is in BLE connection, it can trigger a sound alarm on BLE Central node (for example, a smartphone) by using Button 1. Similarly, BLE Central can trigger LED3 by setting a proper characteristic (for example, by tapping te Find Me button on smartphone application). When not using BLE, nRF52840 SoC acts as a Thread CoAP Server controlling LED4.
Setup
You can find the source code and the makefile in the following folder: <InstallFolder>\examples\multiprotocol\ble_thread\ble_thread_dyn_proximity
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.
The following LEDs reserved for user application purposes are assigned in this example on the multiprotocol node:
- LED3 – Pairing enabled (when toggling) or indicating if Find Me button has been pressed on smartphone.
- LED4 – LED controlled by the CoAP client node.
Button assignments
The following buttons reserved for user application purposes are assigned in this example on the multiprotocol node:
- Button 1 – Trigger a sound alarm on the smartphone when in BLE connection.
- Button 4 – Enable pairing for 5 seconds.
The following buttons reserved for user application purposes are assigned in this example on the client node:
- Button 1 – Toggle LED4 on the server node.
- Button 2 – Toggle LED4 on the multiprotocol node.
Testing
The following testing procedure uses the nRF52840 device.
- Prepare two nRF52840 Preview Development Kits and an Android smartphone (you can also use an iOS smartphone).
- On the smartphone, install nRF Toolbox for BLE.
- Run the following commands to flash the
simple_coap_client
example to one of the boards: $ cd <InstallFolder>/examples/thread/simple_coap_client/hex
$ nrfjprog -f nrf52 -r --program nrf52840_xxaa_pca10056.hex --chiperase
- Switch the board on. This board becomes the CoAP Client node. LED1 starts blinking and then turns solid to indicate that the board is connected to a Thread network.
- Build the example according to the instructions in Building examples.
- Flash SoftDevice and the example according to the instructions in Running examples on the second board.
- Switch the second board on. LED1 starts blinking.
- 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
.
- Open nRF Toolbox and choose the Proximity application.
nRF Toolbox - Proximity application
- Tap ADD DEVICE and select the Thread_Prox device.
nRF Toolbox - Proximity application after establishing the connection
- Observe that LED1 is solid, which indicates that a BLE connection is established.
- Trigger a sound alarm on the smartphone by pressing Button 1.
- Use the Find Me button to toggle LED3 on the nRF52840 Development Kit.
- Note
- This feature may not work correctly on nRF Toolbox running on the newest Android releases.
You can control LED4 on the multiprotocol node by pressing Button 2 on the node with simple_coap_client firmware. No pairing is required for this procedure, because multicast messages are used by the client node.
You can now also control the LED4 on the server node by pressing Button 1 on the client node.