Mistake on this page?
Report an issue in GitHub or email us


Note: Some functions, variables or types have been deprecated. Please see the class reference linked below for details.

Bluetooth low energy (BLE) is a low power wireless technology standard for building personal area networks. Typical applications of BLE are health care, fitness trackers, beacons, smart home, security, entertainment, proximity sensors, industrial and automotive.

Arm Mbed BLE, also called BLE_API, is the Bluetooth Low Energy software solution for Mbed. Many Mbed targets and components support Mbed BLE. Developers can use it to create new BLE enabled applications.

Mbed’s BLE_API interfaces with the BLE controller on the board. It hides the BLE stack’s complexity behind C++ abstractions and is compatible with all BLE-enabled Mbed board. The Mbed OS BLE_API automatically configuring the clocks, timers and other hardware peripherals to work at their lowest power consumption.

BLE_API, bridges and stacks

You can build a BLE application using Mbed OS, BLE_API and a controller-specific Bluetooth stack together with some bridge software to adapt it to BLE_API:

  • BLE_API as described above.
  • The bridge software is specific to each vendor’s board. It provides the instantiations for the interfaces BLE_API offers and helps drive the underlying controller and Bluetooth stack.
  • The Bluetooth stack implements the Bluetooth protocol and is specific to the controller, so a vendor using different controllers may provide different stacks.

Inside BLE_API

BLE_API offers building blocks to help construct applications. These fall into two broad categories:

  1. Interfaces under ble/ to express BLE constructs, such as GAP, GATT, services and characteristics.

  2. Classes under ble/services to offer reference implementations for many of the commonly used GATT profiles. The code under 'services/' isn't essential, but it’s a useful starting point for prototyping. We continue to implement the standard GATT profiles.

The BLEDevice class and header

The entry point of Mbed's BLE_API is the BLE class accessible using the header ble/BLE.h. This class allows you to obtain a BLE object that includes the basic attributes of a spec-compatible BLE device and can work with any BLE radio:

#include "ble/BLE.h"

BLE& mydevicename = BLE::Instance();

The class's member functions can be divided by purpose:

  1. Basic BLE operations, such as initializing the controller.

  2. Accessor to Bluetooth Modules that manage GAP, GATT or the security.


  1. Set up advertising and connection modes.
  2. Assign UUIDs to the service and its characteristic.
  3. Create an input characteristic.
  4. Construct a service class and add it to the BLE stack.
  5. Push notifications when the characteristic's value changes.


To debug issues (or to understand what the stack is doing) it may be helpful to enable tracing.

Traces can be turned on by overriding configuration options in you mbed_app.json:

    "target_overrides": {
        "*": {
            "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

and compiling your application with --profile debug. Please note that with all options enabled your application may become too big - disable some options or lower the mbed-trace.max-level. Detailed documentation is available in the tracing README.md.

All BLE modules contain tracing, each of the modules prefixed with a unique tag:

  • BLE - general BLE traces
  • BLGP - GAP
  • BLGS - GATT Server
  • BLGC - GATT Client
  • BLSM - Security Manager
  • BLDB - Security Database
  • BLHC - HCI
  • BLCO - Cordio stack
  • BLDM - GAP pal
  • BLAT - ATT client

Any contributions to BLE should include appropriate tracing code.

BLE class reference

Data Structures
struct  InitializationCompleteCallbackContext
 Initialization complete event. More...
struct  OnEventsToProcessCallbackContext
 Events to process event. More...
Public Types
typedef unsigned InstanceID_t
 Opaque type used to store the ID of a BLE instance. More...
typedef FunctionPointerWithContext< OnEventsToProcessCallbackContext * > OnEventsToProcessCallback_t
 Events to process event handler. More...
typedef void(* InitializationCompleteCallback_t) (InitializationCompleteCallbackContext *context)
 Initialization complete event handler. More...
Public Member Functions
InstanceID_t getInstanceID () const
 Fetch the ID of a BLE instance. More...
void onEventsToProcess (const OnEventsToProcessCallback_t &on_event_cb)
 Register a callback called when the BLE stack has pending work. More...
void processEvents ()
 Process ALL pending events living in the BLE stack and return once all events have been consumed. More...
ble_error_t init (InitializationCompleteCallback_t completion_cb=nullptr)
 Initialize the BLE controller/stack. More...
template<typename T >
ble_error_t init (T *object, void(T::*completion_cb)(InitializationCompleteCallbackContext *context))
 Initialize the BLE controller/stack. More...
bool hasInitialized () const
 Indicate if the BLE instance has been initialized. More...
ble_error_t shutdown ()
 Shut down the underlying stack, and reset state of this BLE instance. More...
const char * getVersion ()
 This call allows the application to get the BLE stack version information. More...
ble::Gapgap ()
 Accessor to Gap. More...
const ble::Gapgap () const
 A const alternative to gap(). More...
ble::GattServergattServer ()
 Accessor to GattServer. More...
const ble::GattServergattServer () const
 A const alternative to gattServer(). More...
ble::GattClientgattClient ()
 Accessors to GattClient. More...
const ble::GattClientgattClient () const
 A const alternative to gattClient(). More...
ble::SecurityManagersecurityManager ()
 Accessors to SecurityManager. More...
const ble::SecurityManagersecurityManager () const
 A const alternative to securityManager(). More...
void signalEventsToProcess ()
 This function allows the BLE stack to signal that there is work to do and event processing should be done (BLE::processEvent()). More...
Static Public Member Functions
static BLEInstance ()
 Get a reference to the BLE singleton. More...
static BLEInstance (InstanceID_t id)
 Get a reference to the BLE singleton corresponding to a given interface. More...
static const char * errorToString (ble_error_t error)
 Translate error code into a printable string. More...
Static Public Attributes
static const InstanceID_t DEFAULT_INSTANCE = 0
 The value of the BLE::InstanceID_t for the default BLE instance. More...
static const InstanceID_t NUM_INSTANCES = 1
 The number of permitted BLE instances for the application. More...
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.