nRF5 SDK for Thread and Zigbee v1.0.0
BLE UART and Thread MTD CoAP Client Example

This BLE-Thread switched multiprotocol example requires you to run the following example:

BLE-Thread switched MTD CoAP client example

This example application is based on the ble_app_uart example available in nRF5 SDK. It has been modified to support switching between two connection modes, BLE and Thread:

The mode is switched from BLE to Thread in the following situations:

The mode is switched from Thread to BLE in these situations:

LED assignments:

Button assignments:

multi_interaction.png
Interaction of ble_thread_switched_mtd_coap_client and simple_coap_server examples

Setup

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

Testing

  1. Prepare two nRF52840 Preview Development Kits and an Android smartphone.
  2. On the smartphone, install nRF Connect for Mobile.
  3. Run the following commands to flash the simple_coap_server 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/simple_coap_server/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 Connect for Mobile and tap SCAN.
    nrfconnect_1.png
    nRF Connect for Mobile
    Note
    To auto-connect to the BLE device after it finishes operation on Thread network, select Use autoConnect in nRF Connect settings.
  7. Tap CONNECT next to the Nordic_UART device. LED 1 on the ble_thread_switched_mtd_coap_client should be solid.
    nrfconnect_2.png
    nRF Connect for Mobile
  8. Tap Nordic UART Service.
    nrfconnect_3.png
    nRF Connect for Mobile
  9. Tap the arrow pointing up next to TX Characteristic.
    nrfconnect_4.png
    nRF Connect for Mobile
  10. Enter the string led and tap SEND. LED 2 on the ble_thread_switched_mtd_coap_client board will switch on for a few seconds. The BLE connection will be disconnected and the node will start Thread attachment procedure (LED 2 switched on). When the Thread attachment procedure is finished, the node will send a CoAP message to toggle LED on the simple_coap_server board. When the message is received, the simple_coap_server board will toggle LED 4. Then, the ble_thread_switched_mtd_coap_client node will disconnect from the Thread network (LED 2 switched off) and start BLE advertising (LED 1 blinking).
  11. When the ble_thread_switched_mtd_coap_client node starts advertising again, you can repeat the procedure starting from point 5.

Documentation feedback | Developer Zone | Subscribe | Updated