10.2.1.3 Project Generation with Thread CoAP MCC Component

Getting Started

Introduction

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

Recommended Reading

Hardware Requirement

  • WBZ451 Curiosity board
  • Micro USB Cables
  • PC

Software Requirement

Software Requirement for Thread SDK

Additionally, has a dependency on version v1.5.0 of 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: It is recommended that new users of MPLAB Code Configurator go through the overview
  1. Create a new MCC Harmony Project. For more details, refer to 2.5 Creating a New MCC Harmony Project

  2. Open the MPLAB Code Configurator:
    Default MPLAB Code Configurator window :
  3. Click Plus Symbolon the THREAD COAP APP SERVICE component in the Device Resources .The component is part of Wireless - System Services.
  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.
  5. Users are expected to select "yes" for all dependent components. Also, the user has to select "yes" for all attachment auto-connect request.

  6. Right Click on TIME module for selecting the timer source, Select any of the timer.
  7. The project graph will look like the diagram below.
  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.
  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 as shown in the pictures below.
  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
    Right Click on instance0 UART for selecting the uart source, Select SERCOM0.
  11. Click on SERCOM 0 => Go to configuration options => Change Receive pinout, Transmit pinout. Also change the Tx Ring Buffer Size to 256.
  12. Configure the SERCOM0 system setting to enable the Direct High Speed inside system Configuration options → Generate Fuse settings → DEVCFG1.
  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 Generate Code.
  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 14.1  User Action.
  17. This step applicable only if the device is enabled as a sleep end device. Copy the following function definition into the end of the ot_tasks.c file, which is located in the following path: Source Files\config\default\driver\thread\src.

    bool otIsIdle(void)
    {
      if(otTaskletsArePending(instance))
      {
    	return false;
      }
      return true;
    }
    Make changes to the app_thread.c file by uncommenting the following lines of code as shown below:
  18. 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.
  19. Switch to MPLAB X IDE window and Build Project. The project should compile successfully.