nRF5 SDK for Thread v0.11.0
BLE Proximity and Thread CoAP Server Example
This example requires the following SoftDevice: S140

Important: Before you run this example, make sure to program the SoftDevice.

This BLE-Thread dynamic multiprotocol example requires you to run any complementary example on the second board, i.e. an example containing Thread CoAP Client functionality, for example:

This example application is based on the ble_app_proximity 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 may 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, utilizing BLE Proximity and BLE Find Me Profiles. When the device is in BLE connection, it may trigger a sound alarm on BLE Central node (e.g. a smartphone) by using BSP_BUTTON_0. Similarly, BLE Central may trigger BSP_LED_2 by setting a proper characteristic (e.g. by tapping te Find Me button on smartphone application). When not using BLE, nRF52840 SoC acts as a Thread CoAP Server controlling BSP_LED_3.

LED assignments:

Button assignments:

Setup

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

Testing

  1. Prepare two nRF52840 Preview Development Kits and an Android smartphone (you can also use an iOS smartphone).
  2. On the smartphone, install nRF Toolbox for BLE.
  3. Run the following commands to flash the simple_coap_client example to one of the boards and switch it on. LED 1 will start blinking (attaching to a Thread network) and, after a few seconds, it will turn solid (attached to a Thread network or Thread network created):
    $ cd <InstallFolder>/examples/thread/experimental/simple_coap_client/hex
    $ nrfjprog -f nrf52 -r --program nrf52840_xxaa.hex --chiperase
  4. Build the example according to the instructions in Building examples.
  5. Flash SoftDevice and the example according to the instructions in Running examples and switch the board on. LED 1 will start blinking (BLE advertising).
  6. Open nRF Toolbox and choose the Proximity application.
    nrftoolbox_dynamic_prox_1.png
    nRF Toolbox - Proximity application
  7. Tap ADD DEVICE and select the Thread_Prox device.
    nrftoolbox_dynamic_prox_2.png
    nRF Toolbox - Proximity application after establishing the connection
  8. Observe that BSP_LED_0 is solid, which indicates that a BLE connection has been established.
  9. Trigger a sound alarm on the smartphone by pressing BSP_BUTTON_0.
  10. Use the Find Me button to toggle BSP_LED_2 on the nRF52840 Development Kit.
    Note
    This feature may not work correctly on nRF Toolbox running on the newest Android releases.
  11. You can control BSP_LED_3 on the node by pressing BSP_BUTTON _1 on CoAP Client node.
  12. Pair a client with a server. Press BSP_BUTTON_3 on a server node to enable pairing. Then, press BSP_BUTTON_3 on any client node to pair the two nodes.
  13. You can now control the BSP_LED_3 on this server node by pressing BSP_BUTTON_0 on the client node.

Documentation feedback | Developer Zone | Subscribe | Updated