3.2 Bluetooth® Low Energy Legacy Scan

This section guides users in enabling Bluetooth Low Energy Scanning on the Curiosity board using MCC. BLE scanning detects devices in Advertising Mode. Within BLE protocols, either a Central Device or an Observer initiates the scanning process.

Users can either run the precompiled application example .hex file on the Curiosity Board to experience the demo or follow the steps to develop this application from scratch.

It is recommended to follow the examples in order, starting with the basic concepts and then progressing to more advanced topics.

Hardware Requirement

Table 3-3. Hardware Requirement
Tool Qty
Curiosity Board1
Micro USB cable1

Software

  • 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. Precompiled .hex file is located in the path “<Harmony Content Path>\wireless_apps_ble\apps\legacy_scan\hex” folder

  2. 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 the steps mentioned in Running a Precompiled Example
  2. Open and program the application example “legacy_scan_xxxx.X” where xxxx refer to device ( for example: WBZ451, project file: legacy_scan_wbz451.X) located in “<Harmony Content Path>\wirelss_apps_ble\apps\legacy_scan\firmware” using MPLAB X IDE

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

Demo Description

Developing this 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-31. MCC
  3. In the Device Resources window, expand Libraries > Harmony > Wireless > Application Services. Then, click the Plus Symbol to add the BLE Config App Service Component to the project
    Figure 3-32. BLE Config App Service
  4. All BLE Stack related components will be added into the project graph. Please accept dependencies or satisfiers by selecting Yes.
  5. 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.
  6. 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.
  7. For FreeRTOS component settings refer to the Configuring FreeRTOS in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
  8. For WBZ451
    1. Verify if the project graph window has all the expected components, as illustrated in the following figure:
      Figure 3-33. Project Graph
  9. For WBZ351
    1. Verify if the project graph window has all the expected components, as illustrated in the following figure:
      Figure 3-34. Project Graph
  10. Change the BLE Stack Component settings as illustrated in the following figure
    Figure 3-35. BLE Stack

Files Containing User Application Code

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-36. Files

Details on files that user can modify

Table 3-4. 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_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-37. app.c

References

  • Bluetooth Low Energy Legacy Scan Application for: WBZ451
  • Bluetooth Low Energy Legacy Scan Application for: WBZ351