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.
Table 5-6. BLE Provisioning Component MCC Dependencies
Dependency ComponentDependency TypeDescription
Transparent ProfileMandatoryBLE provisioning uses transparent profile as per the functional design.
PDS_SubSystemMandatoryBLE provisioning uses PDS for data backup.
IEEE 802.15.4 PHYMandatoryBLE 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 MACMandatoryBLE provisioning uses the 15.4 MAC if the selected combo application is 15.4 MAC.
Thread StackMandatoryBLE 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.
Figure 5-140. Combo App Configuration Option
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”.
Figure 5-141. Thread Device Role Selection
Figure 5-142. Enable As Sleep End Device

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
Table 5-7. Development Tools
Software Tools and Device Specific Support PackagesVersion
MPLAB X IDEv6.20 or higher
PIC32CX-BZ DFPv1.3.238
XC32 Compilerv4.35
MCCv5.5.0
Table 5-8. Harmony MCC Packages
Package NameVersion
cspv3.18.3
corev3.13.3
bspv3.18.0
dev_packsv3.18.1
CMSIS-FreeRTOSv10.5.1
Cryptov3.8.1
Wolfsslv5.4.0
wireless_pic32cxbz_wbzv1.3.1
wireless_blev1.2.0
wireless_15_4_phyv1.2.0
wireless_15_4_macv1.0.1
wireless_threadv1.1.0
openthreadthread-reference-20230706
wireless_system_pic32cxbz_wbz v1.6.0
Project Generation

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.
  1. Create a new MCC Harmony Project. For more details, refer to Creating a New MCC Harmony Project

  2. From the “Device Resources” field, go to Harmony>Wireless>System Services>BLE PROVISIONING
    Figure 5-143. BLE Provisioning Component
  3. Click on the plus symbol on the BLE PROVISIONING component, as illustrated in the above image.
  4. 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.
    Figure 5-144. Auto-Activation Request
    Figure 5-145. Auto-Connect Request
    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.
    Figure 5-146. Timer Selection for Time Component
    Figure 5-147. Project Graph Complete View
  5. 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.
    Figure 5-148. BLE Provisioning Configuration
  6. Click on the WolfCrypt Library, open Configuration Options and,
    1. Expand WolfCrypt Library>Symmetrical Ciphers>Support AES?> to enable "Support_ECB_Mode" and "Support Hardware Acceleration".
    2. Expand WolfCrypt Library>Support Random Number Generation? to disable "Support Random Number Generation”.
      Figure 5-149. WolfCrypt Library Configuration
  7. Click on the BLE Stack, open Configuration Options and,
    1. 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” as 0xFF03
    2. Expand BLE Stack>Generic Access Profile (GAP)>Advertising>Scan Response Data> to ensure "Local Name" is enabled
    3. Expand BLE Stack>Generic Access Profile (GAP)>Device Name to update the “Device Name” as per the application requirement.
    4. Expand BLE Stack>Generic Access Profile (GAP)>Advertising to update the “Advertising Interval” as per the application requirement.
    Figure 5-150. BLE Stack Configuration
  8. If the device is enabled as “Sleep End Device”. Select Plugins:>Clock Configurations and configure as illustrated in the following image
    Figure 5-151. Clock Configuration
    Figure 5-152. Clock Configuration
    Open Project Graph, and click on the Device Support, open Configuration Options and,
    1. 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.
    Figure 5-153. PMU Mode Settings
    Note: This step is applicable only if the device is enabled as a “Sleep End Device (SED)”.
  9. If console prints is required, user can add a “CONSOLE” component to facilitate application console prints.
    1. Go to “Device Resources” field, and navigate to Libraries>Harmony>System Services and select CONSOLE
      Figure 5-154. CONSOLE Component
    2. In the project graph, right click on ◇ UART>Satisfiers>SERCOM0 to add and connect the SERCOM0 component.
      Figure 5-155. Console Component
    3. Click on the SERCOM0, open Configuration Options and, to change “Receive Pinout” and “Transmit Pinout” as illustrated in the following figure.
      Figure 5-156. SERCOM0 Configurations
    4. Perform the following to configure the “SERCOM0” to enable the Direct High Speed.
      1. In Project Graph, click the System component to open Configuration Options.
      2. To locate “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN)”, navigate to System>Device & Project Configuration>WBZ451 Device Configuration>Generate Fuse Settings>DEVCFG1
      3. Select DIRECT from the drop-down list as illustrated in the following figure.
      Figure 5-157. System Configuration - SERCOM0
  10. 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.

  11. 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.
    Figure 5-158. Combo Application File Structure
  12. Manual code configurations is required for the following files:
    1. app.c File
      1. Open app.c file and include the header files app_prov.h (#include "app_prov/app_prov.h").
      2. In app.c file, within the APP_Tasks function add the following code snippet after the APP_BleStackInit() call, as illustrated in the following figure.
      APP_Prov_TRPS_Init();
      APP_Prov_TRPS_CommissionOnReset();
      Figure 5-159. app.c File
    2. app_ble_handler.c File
      1. Open app_ble_handler.c file (located in Source Files>app_ble>app_ble_handler.c), and include the header file app_ble_conn_handler.h (#include "../app_ble_conn_handler.h").
      2. In app_ble_handler.c file, within the APP_BleGapEvtHandler function add the following code snippet as illustrated in the following figure.
         APP_BleGapConnEvtHandler(p_event);
        
      3. In app_ble_handler.c file, within the APP_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);              
                    }
        Figure 5-160. app_ble_handler.c File
    3. app_trsps_handler.c File
      1. Open app_trsps_handler.c file (located in Source Files>app_ble>app_trsps_handler.c), and include the header file app_trps.h(#include "#include "app_trps/app_trps.h").
      2. In app_trsps_handler.c file, within the APP_TrspsEvtHandler() function add the following code snippet as illustrated in the following figure.
        APP_TRPS_EventHandler(p_event);
        Figure 5-161. app_trsps_handler.c File
    4. app_user_edits.c File
      1. Comment out or remove the #error line. Update the freertos_hooks.c as mentioned in app_user_edits.c file. For more details , refer to User Action.
    5. 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.
      Figure 5-162. Project Properties Tab
      Figure 5-163. Build Project Icon

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.
Table 5-9. BLE Provisioning Specific Control and Command/Response
Commissioning CmdOp CodeCommission Request IDParameterParameter Length (Byte)Commission Response IDCommission Response PayloadCommission Response Payload Length (Byte)Description
GetTechStackType0x8170C0Technology Stack Type1Get supported Technology stack type
GetChannel Mask0x8171C1Channel Mask4Get Channel Mask
SetChannelMask0x8172Channel Mask4C2Set Channel Mask
GetPANID0x8173C3PANID2Get PAN ID
SetPANID0x8174PANID2C4Set PAN ID
GetExtPANID0x8175C5Extended PANID8Get Extended PANID
SetExtPANID0x8176Extended PANID8C6Set Extended PANID
GetNetworkName0x8177C7Network NameUp to 16 bytesGet Network Name
SetNetworkName0x8178Network NameUp to 16 bytesC8Set Network Name
GetNetworkKey0x8179C9Network Key16 bytesGet Network Key
SetNetworkKey0x817ANetwork Key16 bytesCASet Network Key
GetMeshLocalPrefix0x817BCBMesh Local Prefix8 bytesGet Mesh Local Prefix
SetMeshLocalPrefix0x817CMesh Local Prefix8 bytesCCSet Mesh Local Prfix
GetUserParam0x817DCDUser Parameter

16 bytes

Get User Parameter (for future use)
SetUserParam0x817EUser Parameter

16 bytes

CESet User Parameter (for future use)