3.3 Bluetooth® Low Energy Extended Advertisements
This section assists users in enabling Extended Advertisements (1M, 2M, Coded PHY - 125kbps) on the Curiosity Board. This example allows users to send application data using extended advertisements. Extended Advertisements are used to send more data than what legacy advertisements allow and also has long-range functionality when using Coded PHY. Use of Extended Advertisements also enables the users to select between different PHYs (1M, 2M and LE Coded) which are not permitted when using legacy advertisements. In BLE, a peripheral or broadcaster always starts with advertisements. Advertisement packets enable a central or observer to discover a peripheral or broadcaster.
Extended Advertisements implemented in this example can be used for sending more data (2M PHY) or do range tests (Coded PHY). For testing these features, a scanner application can be used which is configured to scan the extended advertisement packets.
To save power, low power mode can be enabled. If conditions are met, then the Curiosity Board will enter into the Sleep mode. The following sections discuss it in detail.
Users can choose to just run the pre compiled application example .hex
file provided on the Curiosity Board and experience the demo or can go through the steps
involved in developing this application from scratch.
These examples each build on top of one another. We strongly recommend following the examples in order, to learn the basic concepts first before progressing to the more advanced topics.
Recommended Reading
- BLE Software Specification
- Getting Started with WME Bluetooth Low Energy Applications
Hardware Required
Tool | Qty |
---|---|
Curiosity Board | 1 (2 if testing with a scanner) |
Micro USB cable | 1 |
Android/iOS Smartphone | 1 |
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
-
Import and program the precompiled
.hex
file: “<Harmony Content Path>\wireless_apps_ble>\apps\ext_adv\hex\
” folder. - 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
- Follow the steps mentioned in Running a Precompiled Example
- Open and program the
application example: “
ext_adv_xxxx.X
” where xxxx refer to device (for example: WBZ451, project file:ext_adv.X
) located in”<Harmony Content Path>\wireless_apps_ble\apps\ext_adv\firmware"
using MPLAB X IDE
For more details on finding the Harmony content path, refer to Installing the MCC Plugin.
Demo Description
Developing the Application from Scratch using MCC
- Create a new MCC Harmony Project by selecting the device. For more details, refer to Creating a New MCC Harmony Project.
- Launch the MCC from the toolbar
as illustrated below. The project graph will open with the default
components.
Figure 3-38. 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-39. BLE Config App Service - All BLE Stack related components will be added into the project graph. Accept dependencies or satisfiers by selecting Yes.
- 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.
- 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 FreeRTOS component settings refer to the Configuring FreeRTOS in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
- For WBZ451
- Change FreeRTOS
Component setting as illustrated in the following figure
Figure 3-40. FreeRTOS Component - Change
Device_Support Component setting as illustrated in the
following figure
Figure 3-41. Device_Support - Verify if the project
graph window has all the expected components. as illustrated in the
following figure:
- Change FreeRTOS
Component setting 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-42. Project Graph
- Verify if the project
graph window has all the expected components. as illustrated in the
following figure:
- Change BLE Stack Component
configuration as illustrated in the following figure:
Figure 3-43. BLE Stack Configuration Figure 3-44. BLE Stack Configuration
Generating a Code
For more details on code generation, refer to the MPLAB Code Configurator (MCC) Code Generation.
Files Containing User Application Code
Details on files that user can modify
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. |
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.app.c
app.c