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
Tool | Qty |
---|---|
WBZ451 Curiosity Board | 2 |
Micro USB cable | 2 |
Android/iOS Mobile | 1 |
Software Requirement
- TeraTerm
-
Microchip Bluetooth Data (MBD) iOS/Android app available in stores
Demo Description
Local RGB LED control (Thread device is not yet commissioned):
FTD/MTD 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.
Programming the Precompiled
.hex
File/Application Example
- Combo FTD Light – One of the WBZ451 Curiosity Board is programmed with combo FTD light application which can act as Leader.
- 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
-
Precompiled Hex files are located in below path in the FTD and MTD folders respectively.
- Combo FTD Light – "<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\multiprotocol\ble_thread_prov_ftd_light\hex"
- Combo MTD Light – "<Harmony Content Path>\wireless_apps_pic32cxbz2_wbz45\apps\multiprotocol\ble_thread_prov_mtd_light\hex"
-
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
-
Follow steps mentioned in the Running a Precompiled Example section
-
Open and program the Application Examples
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 IDEble_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 UsageSensor | Peripheral Used | I/O Pin | Comment |
---|---|---|---|
LED Control | TC2 (WO0, WO1), TC3 (WO0) in PWM Mode | PB0, PB3, PB5 | RGB LED color control. |
Switch | EXTINT0 | PB4 | SW1 button in curiosity board to control MTD/FTD from other MTD/FTD. |
Temperature Sensor | ADC | PB6 | Read the room temperature from the MCP9700A sensor available in the curiosity board |
Timer | RTOS Systick Timer | — | Periodic timer functionality to initiate the sensor read operation and for Adv user LED control |
User LED | GPIO | PB7 | User LED in curiosity board. To indicate BLE advertisement/connect status |
Demo Steps
- 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.
- 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
- Launch the MBD mobile application
- Click on BLE Provisioning feature and select PIC32CXBZ2 to scan for the devices.
- 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
- Connect to the device and follow the screen shots below for the commissioning procedure.
- The Blue "User LED" will be turned ON when device is connected to mobile app.
- 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.
- 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.
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.
- Launch the MBD mobile application.
- Click on BLE Sensor feature and select PIC32CXBZ2 to scan for the devices.
- 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
- Connect to the device and follow the screen shots below for connecting and controlling the RGB LED
- The Blue "User LED" will be turned ON when device is connected to mobile app.
- 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.
- 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.
- 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.
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.