STMicroelectronics UM3051 e X-CUBE-BLEMGR Bluetooth Low Energy Manager Software User Manual

June 4, 2024
STMicroelectronics

STMicroelectronics UM3051 e X-CUBE-BLEMGR Bluetooth Low Energy Manager

Software

Introduction

The X-CUBE-BLEMGR is an expansion software package for STM32Cube for the Bluetooth® Low Energy manager and runs on the STM32. This expansion software includes the STM32_BLE_Manager library, which provides APIs to manage the Bluetooth® LowEnergy service according to the BlueNRG-MS, BlueNRG-1, BlueNRG-2, and BlueNRG-LP middleware APIs.

X-CUBE-BLEMGR software expansion for STM32Cube

Overview
The X-CUBE-BLEMGR software package expands STM32Cube functionality to help the users manage the Bluetooth® Low Energy connectivity, for example with a mobile application such as STBLESensor. The key features are:

  • Sample implementation of a Bluetooth® Low Energy connection to the STBLESensor mobile application
  • STM32_BLE_Manager library to manage the Bluetooth® Low Energy service according to the Bluetooth® Low Energy middleware APIs
  • Sample applications that the developer can use to start experimenting with the code
  • References to free Android and iOS apps that can be used with the sample applications
  • Easy portability across different MCU families, thanks to STM32Cube
  • Free, user-friendly license terms

The sample application creates the following Bluetooth® Low Energy services:

  1. the first service exposes the following characteristics:
    • random values for temperature, pressure, and humidity (randomly evaluated with a dedicated function)
    • random values for the quaternions (randomly evaluated with a dedicated function)
  2. the second is the Console service which includes two characteristics:
    • stdin/stdout with bidirectional communication between the client and the server
    • stderr for a mono-directional channel from the STM32 Nucleo development board to an Android/iOS device
  3. the last service is used to switch the LED on/off and for configuration purposes

Architecture
The proposed software is based on the STM32CubeHAL, the package extends STM32Cube by providing a board support package (BSP) for the BlueNRG-2 network processor (embedded in the BlueNRG-M2SP module) and middleware components for the communication with other Bluetooth® Low Energy devices. The implementation uses low-power consumption strategies suitable for this field of application, compliant with  the Bluetooth® Low Energy specifications core 5.2 (X-NUCLEO- BNRG2A1) for STM32 Nucleo development boards. The provided drivers abstract low-level hardware details, so middleware components and applications can run in a hardware-independent manner.   The package includes a sample application to transmit the values randomly evaluated (temperature, humidity,  pressure, quaternions) to a Bluetooth® Low Energy-enabled device such as an Android™ or iOS™-based smartphone. The software layers used by the application software to access and use the sensor expansion board are:

  • STM32Cube HAL layer: consists of simple, generic, and multi-instance APIs (application programming interfaces) which interact with the upper layer applications, libraries, and stacks. These generic and extension APIs are based on a common framework so that overlying layers like middleware can function without requiring specific microcontroller unit (MCU) hardware information. This structure improves library code reusability and guarantees easy portability across other devices.
  • Board support package (BSP) layer: provides software support for the STM32 Nucleo board peripherals, excluding the MCU. These specific APIs provide a programming interface for certain board-specific peripherals like LEDs, user buttons, etc., and can also be used to fetch individual board version information. It also provides support for initializing, configuring, and reading data.

Figure 1. X-CUBE-BLEMGR software architecture

Folder structure

Figure 2. X-CUBE-BLEMGR package folder structure

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG1

The following folders are included in the software package:

  • Documentation: contains a compiled HTML file generated from the source code, detailing the software components and APIs.
  • Drivers: contains the HAL drivers, the board-specific drivers for each supported board or hardware platform, including the on-board components and the CMSIS vendor-independent hardware abstraction layer for the Cortex-M processor series.
  • Middlewares: contains libraries and protocols for BlueNRG-2 Bluetooth® Low Energy and Bluetooth® Low Energy manager.
  • Projects: contains a sample application that the developer can use to start experimenting with the code to help the users manage the Bluetooth® Low Energy connectivity, for example with a mobile application such as STBLESensor, and provided for the NUCLEO-L476RG through the IAR Embedded Workbench for ARM, RealView Microcontroller Development Kit (MDK-ARM), and STM32CubeIDE development environments.

The installation process
The package binary directory contains an image (in .bin format) for the supported platform. This image can be directly flashed into a supported STM32 Nucleo development board with the STM32CubeProgrammer or via drag and drop.

Figure 3. X-CUBE-BLEMGR binary folder

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG2

APIs
Detailed technical information about the APIs available to the user can be found in a compiled HTML file located inside the “Documentation” folder of the software package where all the functions and parameters are fully described.
Sample application description
A sample application is provided in the projects folder for the X-NUCLEO- BNRG2A1 expansion board connected to the NUCLEO-L476RG development board. Ready-to-build projects are available for multiple IDEs. You can set up a terminal window for the appropriate UART communication port to control the initialization phase.

Figure 4. Terminal settings

When you first press the reset button on the NUCLEO-L476RG development board, the application:

  • starts initializing the UART
  • determines which BlueNRG expansion board is connected to the STM32 Nucleo board
  • recognizes the hardware and firmware version information
  • shows a random Bluetooth® Low Energy MAC address
  • initializes the Bluetooth® Low Energy feature service (temperature, humidity, pressure, LED, and SensorFusion characteristics)
  • initializes the Bluetooth® Low Energy console service adding the stdin/stdout and stderr characteristics
  • initializes the Bluetooth® Low Energy configuration service

Figure 5. UART output initialization

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG4

When an Android/iOS device is connected to the NUCLEO-L476RG board, it is possible to control the data transmitted by the board.

Figure 6. UART output connected

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG5

Android and iOS STBLESensor client application
The X-CUBE-BLEMGR software for STM32Cube is compatible with the STBLESensor Android (version 4.15.0 or higher) or iOS (version 4.15.0 or higher) application available at Google Play or iOS stores. We use the Android application in this example. After the connection, STBLESensor shows the main page below. It displays the random values of temperature, pressure, and humidity.

Figure 7. Environmental data

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG6

The following page shows a cube that rotates starting from the random quaternions values.

Figure 8. MEMS data

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG7

Figure 9. Plot data

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG8

The following page shows the LED on/off control.

Figure 10. LED control

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG9

Through the board configuration page, you can see a few firmware details.

Figure 11. Board report (1 of 2)

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG10

Figure 12. Board report (2 of 2)

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG11

System setup guide

Hardware description

STM32 Nucleo
STM32 Nucleo development boards provide an affordable and flexible way for users to test solutions and build prototypes with any STM32 microcontroller line.  The Arduino connectivity support and ST morpho connectors make it easy to expand the functionality of the STM32 Nucleo open development platform with a wide range of specialized expansion boards to choose from. The STM32 Nucleo board does not require separate probes as it integrates the ST-LINK/V2-1 debugger/ programmer. The STM32 Nucleo board comes with the comprehensive STM32 software HAL library together with various packaged software examples for different IDEs (IAR EWARM, Keil MDK-ARM, STM32CubeIDE, embed and GCC/ LLVM). All STM32 Nucleo users have free access to the embedded online resources (compiler, C/C++ SDK, and developer community) at www.mbed.org to easily build complete applications.

Figure 13. STM32 Nucleo board

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG12

X-NUCLEO-BNRG2A1 expansion board
The X-NUCLEO-BNRG2A1 expansion board provides Bluetooth® Low Energy connectivity for developer applications and can be plugged onto an STM32 Nucleo development board (for example, NUCLEO-L476RG with an ultra-low power STM32 microcontroller) through its Arduino UNO R3 connectors. The expansion board features the Bluetooth® v5.2 compliant and FCC certified BlueNRG-M2SP application processor module based on the ST BlueNRG-2 System-on-Chip. This SoC manages the complete Bluetooth® Low Energy stack and protocols on its Cortex-M0 core and programmable flash memory, which can accommodate custom applications developed using the SDK. The BlueNRG-M2SP module supports master and slave modes, increased transfer rates with data length extension (DLE), and AES-128 security encryption. The X-NUCLEO-BNRG2A1 interfaces with the STM32 Nucleo microcontroller via SPI connections and GPIO pins, some of which can be configured through the hardware.

Figure 14. X-NUCLEO-BNRG2A1 BLE expansion board

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG13

Hardware setup
The following hardware components are needed:

  1. One STM32 Nucleo development platform (order code: NUCLEO-L476RG)
  2. One Bluetooth® Low Energy expansion board (order code: X-NUCLEO-BNRG2A1)
  3. One USB type A to Mini-B USB cable to connect the STM32 Nucleo to the PC

2.3 Software setup
The following software components are required to set up a suitable development environment for creating applications for the STM32 Nucleo equipped with the sensors and the BlueNRG expansion board:

  • X-CUBE-BLEMGR: the Bluetooth® Low Energy manager software for STM32Cube. The X-CUBE-BLEMGR firmware and related documentation is available on www.st.com.
  • Development tool-chain and Compiler: the STM32Cube expansion software supports the three following environments:
    • IAR Embedded Workbench for Arm (IAR-EWARM) toolchain + ST-LINK
    • RealView Microcontroller Development Kit (MDK-ARM-STM32) toolchain + ST-LINK
    • STM32CubeIDE + ST-LINK

After choosing one of the integrated development environments supported by the STM32Cube expansion software, follow the system requirements and setup information provided by the selected IDE provider.

System setup

STM32 Nucleo and sensor expansion board setup
The STM32 Nucleo development board integrates the ST-LINK/V2-1 debugger/programmer. The developer can download the relevant version of the ST-LINK/V2-1 USB driver from STSW-LINK009. The X-NUCLEO-BNRG2A1 BlueNRG Bluetooth® Low Energy expansion board can be easily connected to the STM32 Nucleo through the Arduino UNO R3 extension connector as shown in the figure below.

Figure 15. X-NUCLEO-BNRG2A1 and NUCLEO-L476RG

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG14

X-NUCLEO-BNRG2A1 setup
The procedure described below is required to make the BlueNRG-2 library correctly work with the firmware embedded in the X-NUCLEO-BNRG2A1 Bluetooth® Low Energy module.

  • Step 1. Solder a 0 Ohm resistor to R117 on the X-NUCLEO-BNRG2A1 expansion board.
  • Step 2. Update the X-NUCLEO-BNRG2A1 Bluetooth® Low Energy module through the ST-LINK/V2-1 and the STSW-BNRGFLASHER flasher utility.
  • Step 3. Connect the X-NUCLEO-BNRG2A1 J12 pins to the ST-LINK/V2-1 pins through the 5-wire cable included as shown in the picture below and detailed in Table 1.

Figure 16. The connection between the X-NUCLEO-BNRG2A1 expansion board and ST-LINK/V2-1

STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG15

Table 1. X-NUCLEO-BNRG2A1 and ST-LINK/V2-1 pin connections STMicroelectronics-UM3051-e-X-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-
Software-FIG16

  • Step 4. Install the STSW-BNRGFLASHER and open it.

  • Step 5. Select the SWD tab.
    Figure 17. STSW-BNRGFLASHER – SWD tabSTMicroelectronics-UM3051-e-X-CUBE-
BLEMGR-Bluetooth-Low-Energy-Manager-Software-FIG17.

  • Step 6. Erase the BlueNRG-2 flash memory.
    Figure 18. STSW-BNRGFLASHER – mass eraseSTMicroelectronics-UM3051-e-X
-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-Software-FIG18

  • Step 7. Download the Link Layer Only firmware for the Bluetooth® Low Energy module.

  • Step 8. Load the Link Layer Only firmware into the STSW-BNRGFLASHER and press the [Flash] button.
    Figure 19. STSW-BNRGFLASHER – Flash buttonSTMicroelectronics-UM3051-e-X
-CUBE-BLEMGR-Bluetooth-Low-Energy-Manager-Software-FIG19

  • Step 9. To restore the X-NUCLEO-BNRG2A1 Bluetooth® Low Energy module embedded firmware, repeat the procedure using the following firmware image: DTM_Full.bin. In case of issues during the update process, close the X-NUCLEO-BNRG2A1 J15 jumper before repeating the procedure.

Revision history

Table 2. Document revision historySTMicroelectronics-UM3051-e-X-CUBE-
BLEMGR-Bluetooth-Low-Energy-Manager-Software-FIG20

IMPORTANT NOTICE – READ CAREFULLY

STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgment. Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of purchasers’ products. No license, express or implied, to any intellectual property right is granted by ST herein.  Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product. ST and the ST logo are trademarks of ST. For additional information about ST trademarks, refer to www.st.com/trademarks. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces information previously supplied in any prior versions of this document. © 2022 STMicroelectronics – All rights reserved

References

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

STMicroelectronics User Manuals

Related Manuals