This section helps users to enable scan and connect functionality of the BLE Central
Device on Curiosity Board using MCC. To establish a successful BLE connection, the
Advertiser is required to broadcast advertisement packets across the three primary
advertisement channels (or a subset of these channels). This allows the devices scanning
for advertisers to find and read their advertisement data, the scanner can initiate a
connection if advertiser allows it. To demonstrate a BLE connection on the Curiosity
Board two device types are required.
Advertiser (Transmitting
Connectable Adv)
Scanner
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.
Central Device: Open and
program the application example “central_conn_xxxx.X” where
xxxx refer to device (for example: WBZ451, project file:
central_conn_wbz451.X) located in “<Harmony
Content Path>\wirelss_apps_ble\apps\central_conn\firmware” using
MPLAB X IDE
Peripheral Device: Open
and program the application example “peripheral_conn_xxxx.X”
where xxxx refer to device (for example: WBZ451, project file:
peripheral_conn_wbz451.X) located in “<Harmony
Content Path>\wirelss_apps_ble\apps\peripheral_conn\firmware”
using MPLAB X IDE
Launch the MCC from the toolbar
as illustrated below. The project graph will open with the default
components.Figure 3-77. MCC
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-78. BLE Config App
Service
All BLE Stack related components
will be added into the project graph. Accept dependencies or satisfiers by
selecting Yes.
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.
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.
For FreeRTOS component
settings refer to the Configuring FreeRTOS in Getting Started with
Wireless Made Easy Bluetooth Low Energy Applications from Related
Links.
For WBZ451
Verify if the project
graph window has all the expected components, as illustrated in the
following figure:
For WBZ351
Verify if the project
graph window has all the expected components, as illustrated in the
following figure:
Figure 3-79. Project Graph
Change BLE Stack Component
configuration as illustrated in the following figure. Figure 3-80. 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-81. Files
Details on files that user can modify
Table 3-14. Source Files
Source Files
Usage
app.c
Application State machine, includes calls for Initialization of
all BLE stack (GAP,GATT, SMP, L2CAP) related component
configurations
app_ble_callbacks.c
All the event functions related to GAP, GATT, SMP and L2CAP
events that user can use or modify .
app_utility.c
Contains 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-82. app.c
Figure 3-83. app.c
References
Bluetooth Low Energy Central Connection Application for: WBZ451
Bluetooth Low Energy Central Connection Application for: WBZ351