5.6 Multiprotocol BLE Provisioning MCC Component
Overview
The BLE provisioning component facilitates the users in selecting a combo application.
Additionally, based on the selected combo application option, the user can select the device
role and enable sleep options. The MCC component has certain dependencies, and the following
table outlines these dependencies and their requirements.
Dependency Component | Dependency Type | Description |
---|---|---|
Transparent Profile | Mandatory | BLE provisioning uses transparent profile as per the functional design. |
PDS_SubSystem | Mandatory | BLE provisioning uses PDS for data backup. |
IEEE 802.15.4 PHY | Mandatory | BLE provisioning utilizes the 15.4 PHY when the selected combo application is based on the 15.4 PHY and IEEE 802.15.4 radio services. |
IEEE 802.15.4 MAC | Mandatory | BLE provisioning uses the 15.4 MAC if the selected combo application is 15.4 MAC. |
Thread Stack | Mandatory | BLE provisioning uses the thread stack if the selected combo application is THREAD. |
Component Configuration
The BLE provisioning component facilitates user selection of a combo application
configuration type. The combo application configuration type depends on the respective
stacks, which are activated upon selection. For example, if the user selects the application
configuration type as THREAD, then the Thread stack will be activated.
For the combo application configuration as “THREAD”, user can choose between Full Thread Device (FTD) or Minimal Thread Device (MTD) as the device
roles. For the “MTD” selection, the user can enable the “Sleepy End
Device” option to allow sleep mode in the “MTD”.
Project Generation with Component
This section is designed to guide users through the process of creating a BLE+THREAD multiprotocol project using MPLAB Code Configurator.
Software
Requirement
Project GenerationSoftware Tools and Device Specific Support Packages | Version |
---|---|
MPLAB X IDE | v6.20 or higher |
PIC32CX-BZ DFP | v1.3.238 |
XC32 Compiler | v4.35 |
MCC | v5.5.0 |
Package Name | Version |
---|---|
csp | v3.18.3 |
core | v3.13.3 |
bsp | v3.18.0 |
dev_packs | v3.18.1 |
CMSIS-FreeRTOS | v10.5.1 |
Crypto | v3.8.1 |
Wolfssl | v5.4.0 |
wireless_pic32cxbz_wbz | v1.3.1 |
wireless_ble | v1.2.0 |
wireless_15_4_phy | v1.2.0 |
wireless_15_4_mac | v1.0.1 |
wireless_thread | v1.1.0 |
openthread | thread-reference-20230706 |
wireless_system_pic32cxbz_wbz | v1.6.0 |
This section provides details on the steps required to develop an application based on the BLE Provisioning MCC component, using MCC.
Note: It is recommended that new users of MPLAB Code Configurator to
go through the overview.
-
Create a new MCC Harmony Project. For more details, refer to Creating a New MCC Harmony Project
- From the “Device Resources” field, go to Harmony>Wireless>System Services>BLE PROVISIONING
- Click on the plus symbol on the BLE PROVISIONING component, as illustrated in the above image.
-
Upon selection, user will receive a prompt for auto-activation and auto-connect request of different component dependencies. Select Yes to add all the dependent components and also for all attachment auto-connect requests.Right Click on TIME component on project graph for selecting the timer source (TMR>TC0), select any of the timer. The project graph will resemble the following image.
-
Click on the BLE PROVISIONING, and open Configuration Options to set up the component according to the needs. Follow the steps outlined in the Component Configuration section.
-
Click on the WolfCrypt Library, open Configuration Options and,
- Expand WolfCrypt Library>Symmetrical Ciphers>Support AES?> to enable "Support_ECB_Mode" and "Support Hardware Acceleration".
- Expand WolfCrypt Library>Support Random Number Generation? to disable "Support Random Number Generation”.
- Click on the BLE Stack, open
Configuration Options and,
- Expand BLE Stack>Generic
Access Profile (GAP)>Advertising>Advertising Data> to ensure
"Local Name" is disabled and “Service Data” is enabled. Update the “Service UUID” as
0xDAFE
and “Service Data” as0xFF03
- Expand BLE Stack>Generic Access Profile (GAP)>Advertising>Scan Response Data> to ensure "Local Name" is enabled
- Expand BLE Stack>Generic Access Profile (GAP)>Device Name to update the “Device Name” as per the application requirement.
- Expand BLE Stack>Generic Access Profile (GAP)>Advertising to update the “Advertising Interval” as per the application requirement.
- Expand BLE Stack>Generic
Access Profile (GAP)>Advertising>Advertising Data> to ensure
"Local Name" is disabled and “Service Data” is enabled. Update the “Service UUID” as
-
If the device is enabled as “Sleep End Device”. Select Plugins:>Clock Configurations and configure as illustrated in the following imageOpen Project Graph, and click on the Device Support, open Configuration Options and,
- Expand Device Support>Enable PMU Mode Setting> to ensure "Enable PMU Mode Setting" is enabled and set the “PMU mode” to BUCK_PWM mode (PMU_MODE_BUCK_PWM) to achieve lower power consumption.
Note: This step is applicable only if the device is enabled as a “Sleep End Device (SED)”. -
If console prints is required, user can add a “CONSOLE” component to facilitate application console prints.
- Go to “Device Resources” field, and navigate to Libraries>Harmony>System Services and select CONSOLE
- In the project graph, right click on ◇ UART>Satisfiers>SERCOM0 to add and connect the SERCOM0 component.
- Click on the SERCOM0, open Configuration Options and, to change “Receive Pinout” and “Transmit Pinout” as illustrated in the following figure.
- Perform the following to configure
the “SERCOM0” to enable the Direct High Speed.
- In Project Graph, click the System component to open Configuration Options.
- To locate “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN)”, navigate to System>Device & Project Configuration>WBZ451 Device Configuration>Generate Fuse Settings>DEVCFG1
- Select DIRECT from the drop-down list as illustrated in the following figure.
-
Click on Generate Tab for code generation. Upon code generation, BLE provisioning Component related source files will be added to the project. For more details on code generation, refer to Generate Code section.
-
Once generation completes the header and source files of BLE provision service will be added under project’s Header and Source files based on the configuration.
-
Manual code configurations is required for the following files:
app.c
File- Open
app.c
file and include the header filesapp_prov.h
(#include "app_prov/app_prov.h"
). - In
app.c
file, within theAPP_Tasks
function add the following code snippet after theAPP_BleStackInit()
call, as illustrated in the following figure.
APP_Prov_TRPS_Init(); APP_Prov_TRPS_CommissionOnReset();
- Open
app_ble_handler.c
File- Open
app_ble_handler.c
file (located in Source Files>app_ble>app_ble_handler.c), and include the header fileapp_ble_conn_handler.h
(#include "../app_ble_conn_handler.h"
). - In
app_ble_handler.c
file, within theAPP_BleGapEvtHandler
function add the following code snippet as illustrated in the following figure.APP_BleGapConnEvtHandler(p_event);
- In
app_ble_handler.c
file, within theAPP_BleSmpEvtHandler
function add the following code snippet as illustrated in the following figure.if (p_event->eventField.evtPairingComplete.status != BLE_SMP_PAIRING_SUCCESS) { BLE_GAP_Disconnect(p_event->eventField.evtPairingComplete.connHandle, GAP_DISC_REASON_REMOTE_TERMINATE); }
- Open
app_trsps_handler.c
File- Open
app_trsps_handler.c
file (located in Source Files>app_ble>app_trsps_handler.c), and include the header fileapp_trps.h
(#include "#include "app_trps/app_trps.h"
). - In
app_trsps_handler.c
file, within theAPP_TrspsEvtHandler()
function add the following code snippet as illustrated in the following figure.APP_TRPS_EventHandler(p_event);
- Open
app_user_edits.c
File- Comment out or remove the
#error line. Update the
freertos_hooks.c
as mentioned inapp_user_edits.c
file. For more details , refer to User Action.
- Comment out or remove the
#error line. Update the
-
Switch to MPLAB X IDE window and Build Project. The project must compile successfully. If user encounters the following error “
c:166: undefined reference to `g_adcTiming08
” when adding the BLE Stack, enable the "Remove unused sections" option in the project properties under xc32-ld options.
Protocol Exchange
The communication protocol exchange between BLE Provisioner (mobile app) and the WBZ451 Module (BLE peripheral) is explained in Zigbee Commissioning through BLE -
Protocol Exchange. Following are the additional commands
included.
Commissioning Cmd | Op Code | Commission Request ID | Parameter | Parameter Length (Byte) | Commission Response ID | Commission Response Payload | Commission Response Payload Length (Byte) | Description |
---|---|---|---|---|---|---|---|---|
GetTechStackType | 0x81 | 70 | — | — | C0 | Technology Stack Type | 1 | Get supported Technology stack type |
GetChannel Mask | 0x81 | 71 | — | — | C1 | Channel Mask | 4 | Get Channel Mask |
SetChannelMask | 0x81 | 72 | Channel Mask | 4 | C2 | — | — | Set Channel Mask |
GetPANID | 0x81 | 73 | — | — | C3 | PANID | 2 | Get PAN ID |
SetPANID | 0x81 | 74 | PANID | 2 | C4 | — | — | Set PAN ID |
GetExtPANID | 0x81 | 75 | — | — | C5 | Extended PANID | 8 | Get Extended PANID |
SetExtPANID | 0x81 | 76 | Extended PANID | 8 | C6 | — | — | Set Extended PANID |
GetNetworkName | 0x81 | 77 | — | — | C7 | Network Name | Up to 16 bytes | Get Network Name |
SetNetworkName | 0x81 | 78 | Network Name | Up to 16 bytes | C8 | — | — | Set Network Name |
GetNetworkKey | 0x81 | 79 | — | — | C9 | Network Key | 16 bytes | Get Network Key |
SetNetworkKey | 0x81 | 7A | Network Key | 16 bytes | CA | — | — | Set Network Key |
GetMeshLocalPrefix | 0x81 | 7B | — | — | CB | Mesh Local Prefix | 8 bytes | Get Mesh Local Prefix |
SetMeshLocalPrefix | 0x81 | 7C | Mesh Local Prefix | 8 bytes | CC | — | — | Set Mesh Local Prfix |
GetUserParam | 0x81 | 7D | — | — | CD | User Parameter |
16 bytes | Get User Parameter (for future use) |
SetUserParam | 0x81 | 7E | User Parameter |
16 bytes | CE | — | — | Set User Parameter (for future use) |