6.5.1 FFD Project Creation

Developing the Application from Scratch using MCC

  1. Create a new MCC Harmony Project. For more details, refer to Creating a New MCC Harmony Project from Related Links.

  2. From the “Device Resources” field, go to Harmony>Wireless>Drivers>IEEE 802.15.4>IEEE 802.15.4 MAC
    Figure 6-45. IEEE 802.15.4 MAC Component
    Note: IEEE 802.15.4 PHY and MAC components will appear in Device Resources only if, “wireless_15_4_phy” and “wireless_15_4_mac” repository is cloned in MCC framework path.
  3. Click on the plus symbol on the IEEE 802.15.4 MAC 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.

  5. Click the IEEE 802.15.4 MAC component, and open Configuration Options and
    1. In “Device Type Configuration” field, select FFD from the drop down for FFD project generation
      Note: If security required, select MAC Security Config as Enabled.
      Figure 6-46. IEEE 802.15.4 MAC Configuration
  6. Right click the TIME module for selecting the timer source, and Select TC0.
    Figure 6-47. Timer Component
  7. Click the TIME Component, open Configuration Options and,
    1. Change the Number of Clients as 10 based on software timers.
    Figure 6-48. TIME Configuration
  8. Click PIC32 BZ6 Curiosity BSP under Device Resources (Device Resources>Libraries>Harmony>Board Support Packages>PIC32 BZ6 Curiosity BSP add by using ‘+’ symbol)
    Figure 6-49. Device Resources
  9. From the “Device Resources” field, go to Libraries>Harmony>System Services>BLE Provisioning Add the component by using ‘+’ symbol.
    Figure 6-50. BLE Provisioning
  10. 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 6-51. Auto-Activation Request
  11. Click the BLE Stack, open Configuration Options and,
    1. Expand BLE Stack>Generic Access Profile (GAP)>Device Name to update the “Device Name” as MicrochipFFD.
    2. Expand BLE Stack>Generic Access Profile (GAP)>Advertising>Advertising Data>Local Name to update the “Local Name” as MicrochipFFD
    Figure 6-52. BLE Stack
  12. In the Free-RTOS component , Select Use Timers and ensure to do the following modifications
    1. Set the Timer task priority as 1
    2. Set the Timer queue length as 10
    3. Set the Timer task stack depth as 256
    4. Disable Use Application Daemon Task Startup Hook
    Figure 6-53. Free-RTOS Configuration
  13. Add The “APP_TIMER_SERVICE” component, available in Device Resources>Wireless>System Services> APP_TIMER_SERVICE .
    Figure 6-54. APP_TIMER_SERVICE
  14. Select TCC0 Timer and configure as illustrated in the following figure
    Figure 6-55. Timer Configuration
  15. Select TC3 Timer and configure as illustrated in the following figure
    Figure 6-56. Timer Configuration
  16. Add the CONSOLE component available in Device Resources>System Services>CONSOLE.
    Figure 6-57. CONSOLE
  17. Right click on CONSOLE and add SERCOM0Satisfiers>SERCOM0
    Figure 6-58. SERCOM0
    1. Configure SERCOM0 as illustrated in the following figure
      Figure 6-59. SERCOM0
    2. Click on System component in the project graph and set the SERCOM0 Direct Pin Enable as DIRECT
      Figure 6-60. System Configuration
  18. Ensure that the project graph resembles the one illustrated in the following figure.
    Figure 6-61. Project Graph

Adding Files To The Project

  1. After the successful generation of the project , the following files and folders are added. Copy the following files into the project location from the Project Repository (<Harmony Content Path>\wireless_apps_pic32_bz6\apps\multiprotocol\ble_mac_prov_ffd\firmware\src).
    Figure 6-62. Adding Files To The Project
  2. Add the source and header files to the project as illustrated below
    Figure 6-63. Adding Files To The Project
    1. Add the source file to the project as illustrated below
      Figure 6-64. Adding Files To The Project
    2. Similarly add the header files to the project as illustrated below
      Figure 6-65. Adding Files To The Project
  3. Copy the “sensor folder” to the project directory (from <Harmony Content Path>\wireless_apps_pic32_bz6\apps\multiprotocol\ble_mac_prov_ffd\firmware\src\sensor) and add the “sensor folder” to the project location as illustrated below.
    Figure 6-66. Adding Folder To The Project
    1. Follow step 2 above to add the source and header files, respectively.
    2. To add this folder to include directory, select the Project folder>ble_mac_prov_ffd>Set Configuration>Customize
      Figure 6-67. Adding File to Include Directory
    3. Select xc32-gcc>preprocessing and messages>Include directories>Browse>firmware>sensors>Open
      Figure 6-68. Adding File to Include Directory
  4. Similarly, the app_ffd folder must also be added to the project. Copy the folder to the project directory. Follow Step 2 to add the source and header files, and Step 3 to add the files to the include directory

Code Modifications For FFD project

  • Code changes in app.h file
    Figure 6-69. app.h
  • Code changes in app.c file
    Figure 6-70. app.c
    Figure 6-71. app.c
    Figure 6-72. app.c
    Figure 6-73. app.c
    Figure 6-74. app.c
  • Code changes in app_ble_conn_handler.c file
    Figure 6-75. app_ble_conn_handler.c
    Figure 6-76. app_ble_conn_handler.c
    Figure 6-77. app_ble_conn_handler.c
  • Code changes in app_trps_handler.c file
    Figure 6-78. app_trps_handler.c
    Figure 6-79. app_trps_handler.c
  • Code changes in app_ble_handler.c file
    Figure 6-80. app_ble_handler.c
  • Code changes in app.timer.c file
    Figure 6-81. app.timer.c
    Figure 6-82. app.timer.c