9.2.1.3 Project Generation with Thread CoAP MCC Component

For more details, refer to the Getting Started from Related Links.

Introduction

Thread CoAP example solution application projects are available for reference at <Discover Path>wireless_apps_pic32cxbz3_wbz35\apps\thread\advanced_applications\CoAP. These projects can be generated by following the step-by-step procedure outlined in this document.

Recommended Reading

  • For more details on getting started with thread, refer to the Microchip Thread SDK in the Additional Resources of Reference Documentation from Related Links.

Hardware Requirement

  • WBZ351 Curiosity Board
  • Micro USB Cables
  • PC

Software Requirement

For more details, refer to the Microchip Thread SDK in the Additional Resources section of Reference Documentation from Related Links.

Additionally, it depends on version v1.8.1 of the MCC package wireless_system_pic32cxbz_wbz.

Generating Project

This section explains the steps required to develop this application example from scratch using MPLABx Code Configurator.

Note: The recommendation for the new users of the MPLAB Code Configurator is to refer MPLAB® Code Configurator (MCC) User’s Guide in Reference Documentation from Related Links.
  1. Create a new MCC Harmony Project. For more details, refer to the Creating a New MCC Harmony Project from Related Links.
  2. On the MPLAB X IDE toolbar, look for the icon labeled MCC. Click on the MCC icon to launch the MPLAB Code Configurator.
    Figure 9-7. MPLAB Toolbar – MCC
    1. The following figure illustrates the opening window of the MPLAB Code Configurator.
      Figure 9-8. MPLAB Code Configurator Window
  3. To add “THREAD COAP APP SERVICE” component, perform the following steps:
    1. On the left panel, locate the Device Resources tab.
    2. Click the arrow next to “Wireless” to expand the category.
    3. Under “Wireless”, expand “System Services”.
    4. Click the plus (+) (green) symbol next to THREAD COAP APP SERVICE.
    5. This action adds the component to the project’s Project Graph.
  4. Upon Thread CoAP Component being added to project graph, the different component dependencies will be requested to be added. The user has to select Yes to add all the dependent components.
    Figure 9-9. Components Auto-Activation Confirmation
  5. Users are expected to click Yes for all dependent components.
  6. Right click on TIME module for selecting the timer source, Select any of the timer.
    Figure 9-10. Selecting Timer Source
  7. The following figure illustrates the component project graph.
    Figure 9-11. Thread COAP Component Project Graph
  8. Click on the ‘THREAD COAP APP SERVICE‘, then use the configuration menu to set up the component according to user needs. Follow the steps outlined in the Thread CoAP Component Configuration section.
    Figure 9-12. Thread CoAP Component Configuration
  9. This step is applicable only if the device is enabled as a sleep end device. Select the clock configurations from the plugins and make the following clock configuration changes. The following figure illustrates the clock configuration changes.
    Figure 9-13. Clock Configuration Changes
  10. Add a console component to facilitate application console prints. Users can trigger the console by clicking on the CONSOLE component. The component is a part of System Services.
    Figure 9-14. Adding CONSOLE Component
    1. Right Click on instance0 UART for selecting the UART source, Select SERCOM0.
      Figure 9-15. Selecting SERCOM0 (sercom0) Satisfiers
  11. In the Project Graph, find and click on SERCOM 0 and perform the following steps:
    1. In the Configuration Options tab, locate and change the “Receive Pinout” and “Transmit Pinout” settings.
    2. Click Save or Generate to update the MCC configuration files.
    3. Figure 9-16. Change Receive Pinout
  12. 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 tab.
    2. To locate “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN)”, navigate to System>Device & Project Configuration>WBZ351 Device Configuration>Generate Fuse Settings>DEVCFG1
    3. From the “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN” drop-down list, select DIRECT.
    Figure 9-17. SERCOM0 Direct (High Speed) Pin Enable (SCOMO_HSEN)
  13. Click on Generate Tab for Code generation. Upon code generation, Thread CoAP Component related source files will be added to the project. For more details on code generation, refer to the MPLAB Code Configurator (MCC) Code Generation from Related Links.
  14. Once Generation completes the header, source files of Thread CoAP service will be added under Header and Source Files based on the configuration.
  15. app_user_edits.c file changes: selected line should be commented by following edit step description.
  16. app_user_edits.c file changes: selected line should be commented by following edit step description. For more details, refer to the User Action from Related Links.
  17. According to user needs, the user can modify the Thread network parameters configuration by altering the macros in the file app_thread/app_thread_common.h. Additionally, the user can adjust the Thread sleep period and active period by changing the macro values in the file app_thread.h for APP_THREAD_DEVICE_SLEEP_PERIOD and APP_TIMER_SED_TIMEOUT_PERIOD, if sleep is enabled. Also user can adjust data polling period by changing the macro values in the file src\config\default\driver\thread\inc\openthread_stack_config.h for OPENTHREAD_CONFIG_MAC_ATTACH_DATA_POLL_PERIOD. Change the value to 100 for higher response if sleep is enabled.
  18. Switch to MPLAB X IDE window and Build Project. The project must compile successfully.