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

Table of Contents

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 UART/Serial Port Emulation over BLE 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

Note
The following procedure refers to using an Android smartphone. You can also use an iOS smartphone, but some screenshots can differ, pairing popups can appear, and for an iOS app you must ensure to convert all strings to ASCII HEX codes.
  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 starts blinking (attaching to a Thread network) and, after a few seconds, it turns 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 starts 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. The service information appear.
    nrfconnect_3.png
    nRF Connect for Mobile
  9. Tap the arrow pointing up next to TX Characteristic. The Write value window appears.
    nrfconnect_4.png
    nRF Connect for Mobile
  10. Enter the string led and tap SEND. The following happens:
    • LED 2 on the ble_thread_switched_mtd_coap_client board switches on for a few seconds and the client board starts the Thread attachment procedure.
    • When the Thread attachment procedure is finished, the client board sends a CoAP message to the simple_coap_server board through Thread.
    • When the message is received, the server board toggles LED 4.
    • The client board disconnects the Thread network and LED 2 switches off.
    • The client board starts BLE advertising, and LED 1 starts blinking.
  11. When the ble_thread_switched_mtd_coap_client node starts advertising again, you can repeat the procedure starting from the step where you open nRF Connect for Mobile and tap SCAN.

Documentation feedback | Developer Zone | Subscribe | Updated