nRF5 SDK for Thread and Zigbee v2.0.0
BLE Scanner and Thread SED Example

The BLE Scanner and Thread Sleepy End Device example is a multiprotocol application that demonstrates a device simultaneously acting as a Bluetooth Low Energy Central and as a Sleepy End Device on Thread. Thread operates on the 802.15.4 radio during inactive time of the BLE radio (using Timeslot API). This allows for the application to spend a limited amount of radio time on Thread (as Sleepy End Device) and act as a BLE Central device and perform BLE scanning.

To show all of its functionalities, this BLE-Thread dynamic multiprotocol example requires three nRF52840 Development Kit boards:

LED assignments:

Button assignments:

Setup

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

Testing

To test this example, you need three nRF52840 Development Kits.

  1. Run the following commands to flash the thread_cli example to one of the boards and switch it on:
    $ cd <InstallFolder>/examples/thread/cli/uart/hex
    $ nrfjprog -f nrf52 -r --program nrf52840_xxaa.hex --chiperase
  2. Run the following commands to flash the ble_app_proximity example to one of the boards and switch it on:
    $ cd <InstallFolder>examples/ble_peripheral/ble_app_proximity/hex/ble_app_proximity_pca10056_s140.hex
    $ nrfjprog -f nrf52 -r --program nrf52840_xxaa.hex --chiperase
    LED 1 starts blinking and BLE advertising starts.
  3. Build the BLE Scanner and Thread SED example (see Building examples).
  4. Flash SoftDevice and the example (see Running examples) and switch the board on. The device acts as a Thread Sleepy End Device, so all LEDs are off.
  5. Connect to the board with an RTT such as J-Link RTT Viewer. All the application logs will be printed here.
    <info> app: Thread version: OPENTHREAD/20170716-00812-ge596e1c; NRF52840; Aug 21 2018 16:04:16
    <info> app: Network name: OpenThread
    <info> app: Thread interface has been enabled.
    <info> app: 802.15.4 Channel: 11
    <info> app: 802.15.4 PAN ID: 0xABCD
    <info> app: rx-on-when-idle: disabled
    <info> app: BLE Thread dynamic MTD Scanner example started.
    <info> app: State changed! Flags: 0x000F1215 Current role: 1
  6. Connect to the Thread CLI 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.
  7. Run the following commands to form a Thread network. Use the same network credentials as the BLE Scanner and Thread SED example:
    > panid 0xabcd
    Done
    > channel 11
    Done
    > ifconfig
    Done
    > thread start
    Done
    LED 1 starts blinking (attaching to a Thread network) and, after a few seconds, it turns solid (Thread network created). The multiprotocol device then attaches to the network as a child. You can check the RTT logs:
    <info> app: State changed! Flags: 0x015002A4 Current role: 2
  8. Retrieve RLOC16 address of the multiprotocol device using the following command:
    > child table
    | ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|S|D|N| Extended MAC |
    +-----+--------+------------+------------+-------+------+-+-+-+-+------------------+
    | 1 | 0xc801 | 10 | 2 | 3 | 127 |0|1|0|0| 4a28713522754314 |
    Done
  9. Create an IPv6 address by replacing last two bytes of the following example address with retrieved RLOC16 of the device and ping it on Thread by running the following commands on the Thread CLI board:
    > ping fdde:ad00:beef:0:0:ff:fe00:c801
    > 16 bytes from fdde:ad00:beef:0:0:ff:fe00:c801: icmp_seq=1 hlim=64 time=109ms
    Successful ping proves connectivity over Thread.
  10. Press BSP_BUTTON_0 on the multiprotocol board to trigger a BLE scan. All found devices are visible in the RTT logs. If there is a BLE Proximity device advertising, the application connects to it automatically.
    Scanning started.
    <info> app: === Advertising device found ===
    <info> app: Peer address: e9e8abc2d4b
    <info> app: Proximity service available: true
    <info> app: === Advertising device found ===
    <info> app: Peer address: 211ecd4f1f5a
    <info> app: Proximity service available: false
    <info> app: Connected to e9e8abc2d4b.
    The BSP_LED_0 is now solid.
    Note
    The advertising has a timeout of 180 s. If no BLE Proximity devices are present in the logs, restart the BLE-only board, which resets the time-out timer.

Documentation feedback | Developer Zone | Subscribe | Updated