3.9 Bluetooth® Low Energy Central Transparent UART

This section helps users create a central device and send/receive characters between two connected BLE devices over Microchip proprietary Transparent UART Profile. The central and peripheral devices in this tutorial are two devices. The following instructions are applicable for a BLE Central device.

Users can either choose to run the precompiled application example .hex file on the Curiosity Board and experience the demo or go through the steps involved in developing this application from scratch.

These examples are incrementally structured upon one another. Recommendation is to follow the examples in order, by learning the basic concepts first and then progressing to the more advanced topics.

Hardware Requirement

Table 3-17. Hardware Requirement
Tool Qty
Curiosity Board2
Micro USB cable2

Software Requirement

  • MPLAB X IPE: For programming the precompiled hex file.
  • MPLAB X IDE: For programming the application example.
  • Teraterm: Terminal Emulator for displaying UART output.

Programming the Precompiled Hex File or Application Example

Programming the .hex File using MPLAB X IPE

  1. Central Device: Precompiled .hex file is located in “<Harmony Content Path>\wireless_apps_ble\apps\central_trp_uart\hex” folder
  2. Peripheral Device: Precompiled .hex file is located in “<Harmony Content Path>\wireless_apps_ble\apps\peripheral_trp_uart\hex” folder
  3. For more information on the programming steps, refer to the Programming a Device in MPLAB IPE.
    Note: Users must choose the correct device and tool information.

Programming the Application using MPLAB X IDE

  1. Follow steps mentioned in the Running a Precompiled Example.
  2. Central Device: Open and program the application example “central_trp_uart_xxxx.X” where xxxx refer to device (for example: WBZ451, project file: central_trp_uart_wbz451.X) located in “<Harmony Content Path>\wireless_apps_ble\apps\central_trp_uart\firmware” using MPLAB X IDE
  3. Peripheral Device: Open and program the application example “peripheral_trp_uart_xxxx.X” where xxxx refer to device (for example: WBZ451, project file: peripheral_trp_uart_wbz451.X) located in “ <Harmony Content Path>\wireless_apps_ble\apps\peripheral_trp_uart\firmware” using MPLAB X IDE

For more details on finding the Harmony content path, refer to Installing the MCC Plugin.

Demonstration

Developing the Application from Scratch using MCC

This section explains the steps required by a user to develop this application example from scratch using MCC
Note: It is recommended that new users of MCC to go through the MPLAB® Code Configurator (MCC) User's Guide.
  1. Create a new MCC Harmony Project by selecting the device. For more details, refer to Creating a New MCC Harmony Project.
  2. Launch the MCC from the toolbar as illustrated below. The project graph will open with the default components.
    Figure 3-95. MCC
  3. In the Device Resources window, expand Libraries > Harmony > Wireless > Application Services. Then, click the Plus Symbol to add the Transparent App Service Component to the project
    Figure 3-96. Transparent App Service
  4. All BLE Transparent App Service-related components will be added into the project graph. Accept dependencies or satisfiers by selecting Yes.
  5. For configuring BLE Config App Service component based on the device refer to Adding BLE Config App Service Component to Project Graph and Selecting the Device in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
  6. To enable digital and communication interfaces, refer to Enabling Digital Input/Output and Communication Interfaces Through System Hardware Definition (SHD) component in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
  7. For FreeRTOS component settings refer to the Configuring FreeRTOS in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
  8. Select the Transparent App Service component. In the Configuration Options, then Enable Client Role. Additionally, ensure that the Enable App Code Generation option is enabled.

    Figure 3-97. Transparent App Service
    Figure 3-98. Transparent App Service Configuration
  9. For WBZ451
    1. Verify if the project graph window has all the expected components. as illustrated in the following figure:
      Figure 3-99. Project Graph
    2. Verify FreeRTOS Component setting for Tick Mode and modify as illustrated in the following figure
      Figure 3-100. FreeRTOS Configuration
  10. For WBZ351
    1. Verify if the project graph window has all the expected components, as illustrated in the following figure:
      Figure 3-101. Project Graph
    2. Verify FreeRTOS Component setting for Tick Mode and modify as illustrated in the following figure
      Figure 3-102. FreeRTOS Configuration
    3. Verify SERCOM Component setting for Enable Run in Standby and modify as illustrated in the following figure.
      Figure 3-103. Enable Run in Standby
  11. Enabling the client role option in Transparent App Service component will configure BLE Stack component . Additionally, selecting the Enable App Code Generation option will generate the necessary application files related to the service during the code generation process. Verify the BLE Stack configuration.
    Figure 3-104. BLE Stack Configuration
Source code for the application will be generated from the MCC interface by clicking on Generate Code. User can add or edit the code in the highlighted files as illustrated in the following figure.
Figure 3-105. Files

Details on files that user can modify

Table 3-18. Source Files
Source FilesUsage
app.cApplication State machine, includes calls for Initialization of all BLE stack (GAP,GATT, SMP, L2CAP) related component configurations
app_ble_callbacks.cAll the event functions related to GAP, GATT, SMP and L2CAP events that user can use or modify .
app_trspc_callbacks.cAll the event functions related related to trspc event handles that user can use or modify.
app_utility.cContains generic utility functions that serve the purpose of providing reusable, common functionalities that can be applied across various parts of a program.
Note: app.c is auto generated and has a state machine based application code sample. Users can use this template to develop their application. Main application logic is implemented in void APP_Tasks() function.
Figure 3-106. app.c
Figure 3-107. app.c

References

  • Bluetooth Low Energy Transparent UART Central Application for: WBZ451
  • Bluetooth Low Energy Transparent UART Central Application for: WBZ351