This example demonstrates using the GattClient API to control BLE client devices. The canonical source for this example lives at https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_LEDBlinker

BLE LED Blinker

This example demonstrates using the ``GattClient`` API to control BLE client devices.

The example uses two applications running on two different devices:

  • The first device - the central - runs the application ``BLE_LEDBlinker`` from this repository. This application sends an on/off toggle over BLE.
  • The second device - the peripheral - runs the application ``BLE_LED`` to respond to the toggle.

The toggle simply turns the LED on the peripheral device on and off.

Running the application

Requirements

Hardware requirements are in the main readme.

This example requires *two* devices.

Building instructions

You will need to build both applications and flash each one to a different board.

Please note: The application BLE_LEDBlinker in this repository initiate a connection to all ble devices which advertise "LED" as complete local name. By default, the application BLE_LED advertises "LED" as complete local name. If you change the local name advertised by the application BLE_LED you should reflect your change in this application by changing the value of the constant PEER_NAME in main.cpp.

Tip: You may notice that the application also checks the LED characteristic's UUID; you don't need to change this parameter's value, because it already matches the UUID provided by the second application, BLE_LED.

Building with mbed CLI

If you'd like to use mbed CLI to build this, then you should refer to the main readme. The instructions here relate to using the developer.mbed.org Online Compiler

In order to build this example in the mbed Online Compiler, first import the example using the ‘Import’ button on the right hand side.

Next, select a platform to build for. This must either be a platform that supports BLE, for example the NRF51-DK, or one of the following:

List of platforms supporting Bluetooth Low Energy

Or you must also add a piece of hardware and the supporting library that includes a Bluetooth Low Energy driver for that hardware, for example the K64F or NUCLEO_F401RE with the X-NUCLEO-IDB05A1

List of components supporting Bluetooth Low Energy.

Once you have selected your platform, compile the example and drag and drop the resulting binary onto your board.

For general instructions on using the mbed Online Compiler, please see the mbed Handbook

Checking for success

  • Build both applications and install one on each device, as explained in the building instructions.
  • The LED number two of the device running ``BLE_LED`` should blink.

Monitoring the application through a serial port

You can run ``BLE_LEDBlinker`` and see that it works properly by monitoring its serial output.

You need a terminal program to listen to the output through a serial port. You can download one, for example:

  • Tera Term for Windows.
  • CoolTerm for Mac OS X.
  • GNU Screen for Linux.

To see the application's output:

  • Check which serial port your device is connected to.
  • Run a terminal program with the correct serial port and set the baud rate to 9600. For example, to use GNU Screen, run: ``screen /dev/tty.usbmodem1412 9600``.
  • The application should start printing the toggle's value to the terminal.

Note: ``BLE_LEDBlinker`` will not run properly if the ``BLE_LED`` application is not running on a second device. The terminal will show a few print statements, but you will not be able to see the application in full operation.

History

Merge pull request #252 from donatieng/mbed_os_update default tip

2019-08-15, by mbed_official [Thu, 15 Aug 2019 17:02:05 +0100] rev 81

Merge pull request #252 from donatieng/mbed_os_update

Update Master branch to use Mbed OS 5.13.1
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Updating mbed-os to mbed-os-5.11.5

2019-02-27, by mbed_official [Wed, 27 Feb 2019 13:02:16 +0000] rev 80

Updating mbed-os to mbed-os-5.11.5

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Merge pull request #217 from adbridge/master

2019-02-25, by mbed_official [Mon, 25 Feb 2019 16:44:36 +0000] rev 79

Merge pull request #217 from adbridge/master

Updating mbed-os to mbed-os-5.11.4
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Updating mbed-os to mbed-os-5.11.2

2019-02-13, by mbed_official [Wed, 13 Feb 2019 18:34:58 +0000] rev 78

Updating mbed-os to mbed-os-5.11.2

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Fix SafeEnum comparison.

2019-01-25, by mbed_official [Fri, 25 Jan 2019 15:15:20 +0000] rev 77

Fix SafeEnum comparison.

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Merge pull request #207 from adbridge/master

2019-01-14, by mbed_official [Mon, 14 Jan 2019 11:00:50 +0000] rev 76

Merge pull request #207 from adbridge/master

Updating mbed-os to mbed-os-5.11.1
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Merge pull request #208 from ARMmbed/mbed-os-5.11.0-oob

2019-01-14, by mbed_official [Mon, 14 Jan 2019 10:45:54 +0000] rev 75

Merge pull request #208 from ARMmbed/mbed-os-5.11.0-oob

Mbed OS 5.11.0
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Updating mbed-os to mbed-os-5.10.4

2018-12-14, by mbed_official [Fri, 14 Dec 2018 13:15:46 +0000] rev 74

Updating mbed-os to mbed-os-5.10.4

.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Merge pull request #192 from paul-szczepanek-arm/update-libs

2018-11-16, by mbed_official [Fri, 16 Nov 2018 16:45:35 +0000] rev 73

Merge pull request #192 from paul-szczepanek-arm/update-libs

update libs
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble


Merge pull request #189 from ARMmbed/donatieng-patch-1

2018-11-07, by mbed_official [Wed, 07 Nov 2018 16:30:37 +0000] rev 72

Merge pull request #189 from ARMmbed/donatieng-patch-1

Fix link to health thermometer GATT service
.
Commit copied from https://github.com/ARMmbed/mbed-os-example-ble