5.7 BLE Thread Light Provisioning FTD and MTD Demo Applications

This application demonstrates the multiprotocol functionality of the PIC32CXBZ2 family of devices and modules, which allows for the concurrent operation of both THREAD and BLE stacks. Thread commissioning over BLE uses a Bluetooth Low Energy (BLE) link to exchange Thread network parameters and to run Thread and BLE tasks simultaneously under FreeRTOS. The on board RGB LED, referred to as local lights, can be controlled over BLE. This application was developed using the BLE Provisioning component. For more details on project generation using BLE component, refer to the Project Generation with Component to use the component for application development.

Hardware Requirement

ToolQty
WBZ451 Curiosity Board2
Micro USB cable2
Android/iOS Mobile1

Software Requirement

  • TeraTerm
Smartphone App
  • Microchip Bluetooth Data (MBD) iOS/Android app available in stores

Demo Description

Local RGB LED control (Thread device is not yet commissioned):

When the combo device is not yet commissioned and not connected to Thread network, still would be able to control the RGB LED of the WBZ451 Curiosity Board through BLE using “BLE Sensor” feature of MBD mobile application.
Figure 5-164. BLE Sensor

FTD/MTD Provisioning:

By connecting the device to the "BLE Provisioning" MBD feature, the Thread network of the combo device can be provisioned and connected to the existing Thread network, or it can create a new network (FTD) if there is no nearby network.
Figure 5-165. BLE Provisioning

Local RGB LED Control (Devices are provisioned):

  • The user will be able to control LED of the FTD/MTD via BLE by using the BLE Sensor MBD app.
  • When the LED ON/OFF state is changed via BLE, a change report will be sent to the other FTD/MTD. The status change will be reflected in the other FTD/MTD LED. Also status will be notified to mobile connected to other FTD/MTD.
  • When the LED ON/OFF state is changed from the other FTD/MTD via a button, the state change will be reflected in the BLE Sensor MBD App GUI.
Figure 5-166. BLE Thread Light Combo Control through App
Figure 5-167. BLE Thread Light Combo Control through Button

Programming the Precompiled .hex File/Application Example

To run the demo using Combined Interface as gateway, two devices are required:
  1. Combo FTD Light – One of the WBZ451 Curiosity Board is programmed with combo FTD light application which can act as Leader.
  2. Combo MTD Light – Another WBZ451 Curiosity Board is programmed with combo MTD light application which can act as Thread child.

Programming the .hex File Using MPLAB® IPE

  1. Precompiled Hex files are located in below path in the FTD and MTD folders respectively.
    1. Combo FTD Light – "<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\multiprotocol\ble_thread_prov_ftd_light\hex"
    2. Combo MTD Light – "<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\multiprotocol\ble_thread_prov_mtd_light\hex"
  2. For more details on the steps, go to Programming A Device.

    Note: Users must choose the correct Device and Tool information.

Programming the Application Using MPLAB® X IDE

  1. Follow steps mentioned in the Running a Precompiled Example section

  2. Open and program the Application Examples
    1. ble_thread_prov_ftd_light.X – Located in “<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\multiprotocol\ble_thread_prov_ftd_light\firmware” for FTD using MPLAB X IDE
    2. ble_thread_prov_mtd_light.X – Located in “<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\multiprotocol\ble_thread_prov_mtd_light\firmware” for MTD using MPLAB X IDE

For more details on how to find the Harmony Content Path, refer to Installing the MCC Plugin

On-Board Resource Usage
Table 5-10. On-Board Resource Usage
SensorPeripheral UsedI/O PinComment
LED ControlTC2 (WO0, WO1), TC3 (WO0) in PWM ModePB0, PB3, PB5RGB LED color control.
SwitchEXTINT0PB4SW1 button in curiosity board to control MTD/FTD from other MTD/FTD.
Temperature SensorADCPB6Read the room temperature from the MCP9700A sensor available in the curiosity board
TimerRTOS Systick TimerPeriodic timer functionality to initiate the sensor read operation and for Adv user LED control
User LEDGPIOPB7User LED in curiosity board. To indicate BLE advertisement/connect status

Demo Steps

  1. Supply power to the WBZ451 Curiosity Boards consisting of Combo light FTD and MTD applications by connecting a USB cable. Power Supply (PS) “Green” LED will turn ON when connected to PC.
  2. The application activity is shown in "Console Log" through on board UART-USB converter. Open Terminal (for example, Tera Term) with the following settings.
    Terminal Settings
    • Baud Rate/Speed – 115200 (as configured in SERCOM configuration)
    • Parity – None
    • Data Bits – 8
    • Stop Bits – 1
    • Flow Control – None
Demo Steps: Commissioning Through BLE
  1. Launch the MBD mobile application
  2. Click on BLE Provisioning feature and select PIC32CXBZ2 to scan for the devices.
    Figure 5-168. Scanning and Connecting
  3. The device name "BLE_FTD/MTD_LIGHT_XXXX" will be visible when scanned in the MBD mobile application.
    Note: “XXXX” is a unique number associated with these combo devices
  4. Connect to the device and follow the screen shots below for the commissioning procedure.
    Figure 5-169. Provisioning FTD/MTD Device
  5. The Blue "User LED" will be turned ON when device is connected to mobile app.
  6. If the network parameters are successfully provisioned, the device state can be seen as “Commissioned”. The device will preserve the commissioned data, and it will be used for commissioning from the next power cycle onwards. To clear the commissioned data and provision new data, user has to perform a “Factory Reset” from the “BLE provisioning” feature of the MBD application.
    Figure 5-170. Device State
  7. When the device functions as an FTD by forming a network as a leader, or an MTD by joining as a child, the following log, as illustrated in the following figure, will appear in the console.
    Figure 5-171. Commissioning Terminal Logs

Demo Steps: Light Control

The RGB LED on the WBZ451 Curiosity Board is tied to BLE and Thread functionality. The LED's color and brightness can be changed from a mobile app via BLE, and the status can be transferred through the Thread network. Also, the RGB LED can be turned ON/OFF through the Thread network using user button.

  1. Launch the MBD mobile application.
  2. Click on BLE Sensor feature and select PIC32CXBZ2 to scan for the devices.
    Figure 5-172. Selecting BLE Sensor Sub-App
  3. The device name "BLE_FTD/MTD_LIGHT_XXXX" will be visible when scanned in the MBD mobile application.
    Note: “XXXX” is a unique number associated with these combo devices
  4. Connect to the device and follow the screen shots below for connecting and controlling the RGB LED
    Figure 5-173. Connecting and Controlling RGB LED Using MBD
  5. The Blue "User LED" will be turned ON when device is connected to mobile app.
  6. The “BLE Sensor” feature of MBD application will show the temperature (°C) and LED status received from device, as well as allow the user to vary the RGB color and brightness.
  7. When the RGB LED state is changed via BLE, a change report will be sent to the other FTD/MTD through Thread network if device are connected. The status change will be reflected in the other FTD/MTD LED . Also status will be notified to mobile connected to other FTD/MTD.
  8. Also, user can change LED ON/OFF state of FTD/MTD from other FTD/MTD via button if devices are connected. When the LED ON/OFF state is changed from the other FTD/MTD via a button, the state change will be reflected in the BLE Sensor MBD app.
    Figure 5-174. Console Log Light Control from BLE Sensor App

Protocol Exchange

The communication protocol exchange between BLE Provisioner mobile app/ BLE sensor mobile app (BLE central) and the WBZ451 module (BLE peripheral) is explained in Protocol Exchange.