Main Content

Bluetooth Low Energy Communication Overview

Bluetooth® Low Energy is a wireless communication protocol for discovering and communicating with low-power peripheral devices. Bluetooth Low Energy support in MATLAB® allows you to:

  • Scan for nearby peripheral devices and view their advertisement data.

  • Establish a connection between your computer and peripheral devices.

  • Read and write characteristic and descriptor data.

  • Subscribe to characteristics to enable notification or indication.

Bluetooth Low Energy Communication in MATLAB is different from Bluetooth Communication and the functionalities supported by Bluetooth Toolbox. To understand the use cases for each feature and to decide which one best fits your needs, refer to the documentation for each.

Prerequisites and Setup

To use the Bluetooth Low Energy interface in MATLAB, you need the following:

  • A peripheral device that supports Bluetooth 4.0 or higher

  • A built-in or external Bluetooth 4.0 adapter on your computer

  • MATLAB installed on your computer

Make sure your computer has Bluetooth turned on. The peripheral device that you are scanning for must be near your computer and disconnected from other devices and applications.

Bluetooth Low Energy Concepts

The Bluetooth Low Energy communication is based on the Generic Access Profile (GAP) protocol for device discovery and the Generic Attribute (GATT) protocol for device communication. Both of these protocols are documented in detail on the Bluetooth SIG website. Although specific knowledge about GAP and GATT is not necessary to communicate with Bluetooth Low Energy devices in MATLAB, there are a few important concepts to understand.

During discovery, devices are either central devices or peripheral devices.

  • A central device scans for advertisement data from other devices. In the Bluetooth Low Energy interface in MATLAB, your computer is always the central device.

  • A peripheral device transmits advertisement data. Peripheral devices are nearby devices that you are scanning for. Peripheral devices include fitness trackers, health monitors, and personal electronics such as smartwatches or wireless headphones.

After discovering the peripheral devices, you can connect to multiple peripheral devices from MATLAB at the same time. For more information about scanning for and connecting to peripheral devices, see Find Your Bluetooth Low Energy Peripheral Devices.

After establishing a connection between MATLAB on your computer and a Bluetooth Low Energy peripheral device, the two have a client-server relationship. The server is the device that contains data, while the client is the device that receives the data and performs a function.

Services, Characteristics, and Descriptors

The building blocks of Bluetooth Low Energy device communication are services, characteristics, and descriptors. All three of these play a role in reading from and writing to peripheral devices in MATLAB. In peripheral devices, their functions are as follows:

  • Services are collections of related characteristics. Services are not readable or writable, but the characteristics that they contain can be. For example, the Heart Rate service includes both the Heart Rate Measurement and Body Sensor Location characteristics.

  • Characteristics contain values for user data or device data. This is the primary attribute of the peripheral device that you want to read. For example, the Heart Rate Measurement characteristic is a standard characteristic commonly found on fitness trackers. You can read or write characteristic values.

  • Descriptors describe characteristic values. Each characteristic can have one or more descriptors associated with it. A descriptor contains metadata about the characteristic value being measured. For example, the Client Characteristic Configuration Descriptor is a descriptor that determines whether the device is currently collecting characteristic data or not. You can read or write descriptor values.

All three of these can be standard or custom. Standard services, characteristics, and descriptors are defined by the Bluetooth SIG, while custom services, characteristics, and descriptors are usually specific to the device or device manufacturer.

In the Bluetooth Low Energy interface in MATLAB, you can use read and write on characteristic and descriptor objects. You can also use subscribe and unsubscribe with characteristic objects. For more information about how to perform these operations, see Work with Device Characteristics and Descriptors.

See Also

| | | | | | |

Related Topics

External Websites