• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

BLE demos using mbed OS and mbed cli

BLE Examples

This repo contains a collection of BLE example applications based on Mbed OS. Each example subdirectory contains a separate Mbed OS project, along with a description of the example and additional instructions for running it.

You can build each project with all supported Mbed OS build tools. However, this file specifically refers to the command-line interface tools, Arm Mbed CLI 1 and Mbed CLI 2.

The BLE documentation describes the BLE APIs on Mbed OS.

Mbed OS build tools

Mbed CLI 2

Starting with version 6.5, Mbed OS uses Mbed CLI 2. It uses Ninja as a build system, and CMake to generate the build environment and manage the build process in a compiler-independent manner. If you are working with Mbed OS version prior to 6.5 then check the section Mbed CLI 1.

Install Mbed CLI 2.

Mbed CLI 1

Install Mbed CLI 1.

Pre-Requisites

In order to use BLE in Mbed OS you need one of the following hardware combinations:

The BLE documentation describes the BLE APIs on mbed OS.

Targets for BLE

The following targets have been tested and work with these examples:

  • Targets with an ST BLE expansion board plugged in:

    • NUCLEO_F401RE
    • NUCLEO_L476RG
    • NUCLEO_L446RE
    • K64F
  • ST boards with embedded SPBTLE-RF module (BlueNRG-MS):

    • DISCO_L475VG_IOT01A (ref B-L475E-IOT01A)
    • DISCO_L562QE (ref STM32L562E-DK)
  • Board with wireless STM32WB microcontrollers:

    • NUCLEO_WB55RG
  • Nordic:

    • NRF52_DK
    • NRF52840_DK
  • Embedded Planet:

    • EP_AGORA

Important: If an ST BLE expansion is used with the K64F board, a hardware patch is required. Check out X-NUCLEO-BNRG2A1 or X-NUCLEO-IDB05A1 for more information.

The following board is currently not supported as it doesn't yet support the Cordio stack: * NRF51_DK

Using ST BLE expansion board on other targets

It is possible to use the ST BLE expansion on boards not directly supported by these examples as long as the board has an Arduino UNO R3 connector.

To make the board compatible with the ST BLE expansion three things are required:

  • Add the BLE feature to your target.
  • Add the BLE implementation for the ST BLE expansion to the list of modules which have to be compiled.
  • Indicate to the BLE implementation that your board uses an Arduino connector.

All these operations can be done in the file mbed_app.json present in every example.

In the section target_overrides, add a new object named after your target with the following three fields:

  • "target.components_add": ["BlueNRG_2"] Add the BlueNRG-2 component to the target.
  • "target.features_add": ["BLE"] Add the BLE feature to the target.
  • "target.extra_labels_add": ["CORDIO"]: Add the BLE implementation of the ST BLE expansion to the list of the application modules.

Below is an example of the JSON to be added in the target_overrides section of mbed_app.json, with the NUCLEO_F401RE board.

        "NUCLEO_F401RE": {
            "target.components_add": ["BlueNRG_2"],
            "target.features_add": ["BLE"],
            "target.extra_labels_add": ["CORDIO"]
        },

Note: Further information about the configuration system is available in the documentation.

Important: It is required to apply an hardware patch to the ST BLE expansion if it is used on a board with an Arduino connector. Check out X-NUCLEO-BNRG2A1 or X-NUCLEO-IDB05A1 for more information.

Building the examples

  1. Clone the repository containing the collection of examples:

    $ git clone https://github.com/ARMmbed/mbed-os-example-ble.git

    Tip: If you don't have git installed, you can download a zip file of the repository.

  2. Using a command-line tool, navigate to any of the example directories, like BLE_Advertising:

    $ cd mbed-os-example-ble
    $ cd BLE_Advertising
  3. Update the source tree:

    • Mbed CLI 2
    $ mbed-tools deploy
    • Mbed CLI 1
    $ mbed deploy
  4. Connect a USB cable between the USB port on the board and the host computer.

  5. Run the following command: this will build the example project, program the microcontroller flash memory, and then open a serial terminal to the device.

    • Mbed CLI 2
    $ mbed-tools compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm --baudrate 115200
    • Mbed CLI 1
    $ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm --baudrate 115200

Your PC may take a few minutes to compile your code.

The binary will be located in the following directory:

  • Mbed CLI 2 - ./cmake_build/<TARGET>/<PROFILE>/<TOOLCHAIN>/
  • Mbed CLI 1 - ./BUILD/<TARGET>/<TOOLCHAIN>/

You can manually copy the binary to the target, which gets mounted on the host computer through USB, rather than using the --flash option.

You can also open a serial terminal separately, as explained below, rather than using the --sterm and --baudrate options.

Running the examples

When example application is running, information about activity is printed over the serial connection. The default serial baudrate has been set to 115200 for these examples.

If not using the --sterm and --baudrate options when flashing, have a client open and connected to the board. You may use:

  • Mbed CLI 2

    $ mbed-tools sterm -b 115200
  • Mbed CLI 1

    $ mbed sterm -b 115200
  • Tera Term for Windows

  • screen or minicom for Linux

    screen /dev/serial/<your board> 115200

To observe and/or interact with example applications please use any BLE scanner on a smartphone. If you don't have a scanner on your phone, please install:

Using bare metal profile

MBED BLE can support bare metal profile: https://os.mbed.com/docs/mbed-os/v6.10/bare-metal/using-the-bare-metal-profile.html

Here is an example with NUCLEO_WB55RG, update your local mbed_app.json:

{
    "requires": ["bare-metal", "events", "cordio-stm32wb"],

How to reduce application size

Here are few tips to reduce further application size (this could be in addition of baremetal)

Update in mbed_app.json:

{
    "target_overrides": {
        "*": {
            "target.c_lib": "small",
            "target.printf_lib": "minimal-printf",
            "platform.minimal-printf-enable-floating-point": false,
            "platform.stdio-minimal-console-only": true,
...

Troubleshooting

If you encounter problems with running the example, first try to update to the development branch of the example and see if the problem persists. Make sure to run mbed update after you checkout the development branch to update the libraries to the versions in that branch.

If the problem persists, try turning on traces in the example. This is done by changing the config in mbed_app.json:

		"mbed-trace.enable": true,
		"mbed-trace.max-level": "TRACE_LEVEL_DEBUG",
		"cordio.trace-hci-packets": true,
		"cordio.trace-cordio-wsf-traces": true,
		"ble.trace-human-readable-enums": true

Compile with --profile debug and run with the serial connected to your PC.

This will enable all the traces in BLE. If the number of traces is too big for the serial to handle or the image doesn't fit try turning off all except the first one (mbed-trace.enable) and/or lowering the max-level to "TRACE_LEVEL_WARNING".

Save the output of the serial to a file. Please open an issue in this repo, describe the problem and attach the file containing the trace output.

License and contributions

The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see CONTRIBUTING.md for more info.

Branches

Master branch is for releases only. Please target the development branch for all your PRs.

More Repositories

1

mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
C
4,650
star
2

DAPLink

C
2,272
star
3

mbed-cli

Arm Mbed Command Line Interface
Python
333
star
4

mbed-HDK

DEPRECATED mbed HDK - This repository is not being maintained. For the latest updates, please use: https://github.com/ARMmbed/mbed-HDK-Eagle-Projects
SMT
170
star
5

mbed-HDK-Eagle-Projects

Collection of Eagle projects for targets, interfaces, shields and more
SMT
167
star
6

yotta

DEPRECATED: yotta build; better software
Python
163
star
7

uvisor

DEPRECATED mbed OS uVisor -- device security layer for ARMv7M microcontrollers
C
132
star
8

homebrew-formulae

homebrew ("the missing package manager for OS X") formulae from the mbed team.
Ruby
118
star
9

mbed-crypto

The development of Mbed Crypto has moved to Mbed TLS. No updates will be made to the mbed-crypto repository anymore.
C
103
star
10

mbed-os-5-docs

Full documentation for Mbed OS 5 and 6
Python
98
star
11

dapjs

JavaScript interface to CMSIS-DAP
TypeScript
84
star
12

ble

API to abstract working with Bluetooth Smart Controllers
C++
80
star
13

mbed-os-example-lorawan

Simple LoRaWAN example application for mbed OS
C++
79
star
14

mbed-os-example-lorawan-fuota

Mbed OS 5 Firmware update over LoRaWAN example application
C++
66
star
15

mbed-littlefs

[experimental] Mbed OS wrapper for LittleFS v2.0 (alpha)
C
65
star
16

mbed-client

DEPRECATED: C++ API for mbed-client
C++
53
star
17

mbed-os-example-bootloader

DEPRECATED: example
C++
47
star
18

mbed-mqtt

Mbed-os MQTT and MQTT-SN library, based on Eclipse Paho project.
C++
46
star
19

mbed-os-linker-report

Post-processing of linker output to calculate and visualize memory usage for elf-sections
JavaScript
46
star
20

ble-nrf51822

Nordic stack and drivers for the mbed BLE_API
C++
45
star
21

mbed-os-example-blinky

Blinky example for Mbed OS 6.0
CMake
42
star
22

mbed-tools

โš ๏ธ Beta Status: New command line tooling for Mbed OS
Python
41
star
23

mbed-drivers

Drivers for common MCU peripherals in mbed OS.
C++
39
star
24

mbed-os-example-mesh-minimal

Simplest Mesh capable test application for mbed OS
C
35
star
25

ATParser

Parser for AT commands and similar protocols.
C++
34
star
26

mbed-cli-windows-installer

Windows installer for mbed CLI
NSIS
33
star
27

sal-stack-nanostack

IPv6+6LoWPAN+Thread stack for mbed OS.
31
star
28

dlmalloc

Doug Lea's malloc
C
31
star
29

mbed-os-example-tls

mbed TLS Sample application
C
30
star
30

mbed-os-tools

The tools to test and work with Mbed OS
Python
30
star
31

mbed-semtech-lora-rf-drivers

Semtech's LoRa RF drivers for mbed OS
C++
27
star
32

greentea

IoT reGREssion ENvironment for TEst Automation
Python
27
star
33

spif-driver

Block device driver for NOR SPI flash devices that support SFDP, such as the MX25R or SST26F016B
C++
26
star
34

nrf5x-dfu-bootloader

DEPRECATED
C
25
star
35

ble-examples

BLE demos using mbed OS 3 and yotta.
C++
24
star
36

minar

mbed OS scheduler
C++
24
star
37

mbed-os-example-wifi

DEPRECATED: Wi-fi example for Mbed OS 6
C++
23
star
38

lwip

Fork of master lwIP repository
C
23
star
39

mbed-ls

MOVED: https://github.com/ARMmbed/mbed-os-tools (mbedls detects Mbed Enabled devices connected to your computer)
23
star
40

mbed-os-example-sockets

Simple example for the network-socket API
C++
20
star
41

mbed-os-example-client

DEPRECATED: This is the mbed Client example application for mbed OS.
C++
20
star
42

mbed-os-example-cellular

This is an example based on mbed-os cellular APIs that demonstrates a TCP or UDP echo transaction with a public echo server.
C++
19
star
43

stm32customtargets

Enable the support of your custom boards in mbed-os 6
C
19
star
44

mbed-client-example-6lowpan

DEPRECATED: Example demonstrating 6LoWPAN mesh networking
C++
19
star
45

suit-manifest-generator

C
18
star
46

GettingStartedmbedOS

Source files for the mbed OS User Guide - please read on the website
17
star
47

mbed-js-example

Basic Example for JavaScript on mbed
JavaScript
16
star
48

lorawan-fota-demo

Superseded by https://github.com/armmbed/mbed-os-example-lorawan-fuota
C++
16
star
49

mbed-client-quickstart

DEPRECATED: Mbed Client example program.
C++
16
star
50

wifi-ism43362

ISM43362 WiFi driver
C++
15
star
51

esp8266-driver

Deprecated: outdated ESP8266 Mbed OS driver
15
star
52

mbed-hal

mbed low-level HAL API
C
15
star
53

mbed-tls-sockets

A C++ Sockets-like API for mbed TLS
C++
14
star
54

mbed-access-point

mbed Access Point based on OpenWrt
C
14
star
55

ble-x-nucleo-idb0xa1

port of BLE_API to ST BLE shield
C
14
star
56

easy-connect

DEPRECATED: Easily add all supported connectivity methods to your mbed OS project
C++
14
star
57

mbed-os-example-filesystem

The Mbed OS file system example
C++
14
star
58

mbed-os-bluetooth-integration-testsuite

Mbed OS test suite for Bluetooth integration
C++
13
star
59

mbed-os-example-pelion

Mbed OS example for Pelion Device Management
C++
13
star
60

mbed-os-example-atecc608a

Mbed OS Examples for the ATECC608A
C
13
star
61

mbed-cli-osx-installer

DEPRECATED installer for Mbed CLI on OS X
Python
13
star
62

mbed-os-example-for-aws

Mbed OS example to connect to AWS IoT Core
C++
12
star
63

nrf51-sdk

Module to contain files provided by the nordic nRF51 SDK
C
12
star
64

core-util

DEPRECATED: Mbed 3 utilities library
C++
12
star
65

mbed-webapp-example

Example java web application that run on top of mbed Device Server
Java
11
star
66

mbed-events

DEPRECATED! This project has moved to mbed-os
C++
11
star
67

post-mortem-debugging

Post mortem debugging with CMSIS-DAP and DAPLink
Python
10
star
68

lora-docs

Getting started with LoRa and mbed
JavaScript
10
star
69

mbed-flasher

mbed device flasher application
Python
10
star
70

ble-ancs-client

Demo for the ANCS client.
C++
9
star
71

dali-based-driver-for-mbedos

DALI-based Driver for Mbed OS
C++
9
star
72

BLEIntros

DEPRECATED BLE intro texts
9
star
73

mbed-js-v2

Work in progress - for mbed.js see https://github.com/armmbed/mbed-js-example
C++
9
star
74

ci-test-shield

mbed CI Test Shield
C++
9
star
75

mbed-hal-nrf51822-mcu

mbed HAL port for nRF51822
C
9
star
76

cmsis-debug-adapter

Debug adapter for CMSIS-DAP using GDB MI
TypeScript
9
star
77

uvisor-lib

DEPRECATED: This repo is deprecated and only for historical purposes only - see https://github.com/ARMmbed/uvisor
CMake
9
star
78

mbed-client-for-aws

AWS IoT SDK port for Mbed OS
C++
8
star
79

htrun

MOVED: https://github.com/ARMmbed/mbed-os-tools (Flash, reset and run host supervised tests on mbed platforms)
8
star
80

mbed-os-example-sd-driver

mbed-os example for the sd-driver (SDCard) block device driver (SDBlockDevice)
C++
7
star
81

mbed-hal-st-stm32f4

mbed HAL for ST STM32F4-series microcontrollers
C
7
star
82

wearable-reference-design

Wearable Reference Design main GitHub page.
7
star
83

mbed-nfc-nt3h2111

NFC driver for NXP NT3H2111
C++
7
star
84

i2cee-driver

[experimental] Block device driver for I2C EEPROM devices
C++
7
star
85

wearable-reference-design-example-user-interface

Example application demonstrating the user interface on the Wearable Reference Design.
C++
7
star
86

mbed-js-ble-example

BLE Example for JerryScript on mbed
JavaScript
7
star
87

fpga-ci-test-shield

Verilog source code, tests and utilities for the FPGA CI Test Shield
Verilog
7
star
88

utest

utest: Asynchronous C++ Test Harness for embedded targets
C++
7
star
89

dataflash-driver

Block device driver for DataFlash devices
C++
7
star
90

mbed-os-docker-images

mbed docker-hub Dockerfiles
Dockerfile
6
star
91

mbed-mesh-api

Mesh network API.
6
star
92

sockets

mbed sockets library abstraction layer
C++
6
star
93

valinor

Generate Project Files to Debug ELF files.
Python
6
star
94

sdio-driver

SDIO block device driver
6
star
95

stm-spirit1-rf-driver

Prototype RF driver for STM Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo
C
6
star
96

mbed-os-example-for-azure

Mbed OS example to connect to Azure IoT Hub
C++
6
star
97

icetea

DEPRECATED mbed test framework
Python
6
star
98

mbed-os-experimental-ble-services

Incubator of Bluetooth services
C++
6
star
99

hackathon

mbed Hackathon @ โ€ŽCambridge University Engineering Society
C
6
star
100

target-mbed-gcc

DEPRECATED Base for mbed yotta compilation targets compiling with GCC
CMake
6
star