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.

Revisions of mbed-os.lib

Revision Date Message Actions
52:797fc620e4d2 2018-01-09 Merge pull request #129 from adbridge/master File  Diff  Annotate
50:edaaab61d692 2017-12-20 Merge pull request #126 from ARMmbed/mbed-os-5.7.0-oob File  Diff  Annotate
49:2fe76892ad76 2017-12-05 Merge pull request #119 from adbridge/master File  Diff  Annotate
48:cb1d091fad7d 2017-11-23 Merge pull request #115 from adbridge/master File  Diff  Annotate
47:920438061d32 2017-11-07 Merge pull request #113 from adbridge/master File  Diff  Annotate
46:5317d0d02e0f 2017-11-03 Merge pull request #110 from 0xc0170/master File  Diff  Annotate
44:1ef876d2a049 2017-10-11 Merge pull request #108 from adbridge/master File  Diff  Annotate
43:aa4eca84d71a 2017-09-29 Merge pull request #106 from 0xc0170/master File  Diff  Annotate
42:59bdc0cf8b36 2017-09-20 Merge pull request #103 from ARMmbed/5.6_sanity File  Diff  Annotate
41:23b05cc8a158 2017-09-08 Merge pull request #102 from adbridge/master File  Diff  Annotate
40:38475206d9c9 2017-08-08 Merge pull request #100 from 0xc0170/master File  Diff  Annotate
38:ed69923f4965 2017-07-19 Merge pull request #97 from 0xc0170/master File  Diff  Annotate
36:c22b5f6d32b4 2017-07-11 Merge pull request #93 from adbridge/master File  Diff  Annotate
35:947ef4c45474 2017-06-22 Merge pull request #89 from adbridge/master File  Diff  Annotate
33:7e92b7625efa 2017-06-20 Merge pull request #88 from adbridge/master File  Diff  Annotate
31:7e8fbd60a611 2017-06-08 Merge pull request #82 from adbridge/master File  Diff  Annotate
30:dd9909a5bf02 2017-05-25 Merge pull request #81 from adbridge/master File  Diff  Annotate
29:628273dfb8f8 2017-05-10 Merge pull request #79 from adbridge/master File  Diff  Annotate
27:9fde1d0514c1 2017-05-09 Merge pull request #77 from 0xc0170/master File  Diff  Annotate
26:6be3dcdca4ea 2017-04-05 Merge pull request #70 from 0xc0170/master File  Diff  Annotate
23:27f72f0c8c26 2017-03-14 Merge pull request #68 from adbridge/master File  Diff  Annotate
22:290659788ea9 2017-03-09 Merge pull request #66 from ARMmbed/oob_test_mbed-os-5.4 File  Diff  Annotate
21:3cce4cf01994 2017-03-01 Merge pull request #55 from adbridge/master File  Diff  Annotate
19:10aa43608159 2017-02-15 Merge pull request #52 from 0xc0170/master File  Diff  Annotate
18:bdd1a35bf571 2017-02-02 Merge pull request #48 from adbridge/master File  Diff  Annotate
17:04578e106bd6 2017-01-26 Merge pull request #46 from adbridge/master File  Diff  Annotate
16:569c76364f88 2016-12-15 Update mbed-os revision to mbed-os 5.3.0. File  Diff  Annotate
15:7feffdbad68a 2016-12-15 Merge pull request #42 from ARMmbed/mbed-os-5.3.0-rc3 File  Diff  Annotate
14:a7b3ffdced34 2016-10-28 Updating mbed-os to mbed-os-5.2.1 File  Diff  Annotate
13:aa8d946cac64 2016-10-24 Updating mbed-os to mbed-os-5.2.0 File  Diff  Annotate
12:059c7b7fb18a 2016-10-24 Merge pull request #32 from ARMmbed/oob File  Diff  Annotate
11:81616ecf4497 2016-10-05 Updating mbed-os to mbed-os-5.1.5 File  Diff  Annotate
10:2b4e449ea2dc 2016-09-16 Updating mbed-os to mbed-os-5.1.4 File  Diff  Annotate
9:a3da3da3663e 2016-08-20 Updating mbed-os to mbed-os-5.1.2 File  Diff  Annotate
8:7367d645b7ec 2016-08-19 Updating mbed-os to mbed-os-5.1.1 File  Diff  Annotate
7:861f38bb217a 2016-08-05 Updating mbed-os to mbed-os-5.1.0 File  Diff  Annotate
5:d878c64fdd23 2016-08-03 Updating mbed-os to mbed-os-5.1.0-rc5 File  Diff  Annotate
3:4129ec2e8b70 2016-07-30 Updating mbed-os to mbed-os-5.1.0-rc4 File  Diff  Annotate
2:3f5a4729c22b 2016-07-28 Merge branch 'master' of https://github.com/ARMmbed/mbed-os-example-ble File  Diff  Annotate
1:959c0ea99fae 2016-07-28 Sync with mbed-os-5.1.0-rc3 File  Diff  Annotate
0:86bf1d2040b3 2016-07-26 Update example at tag mbed-os-5.0.1-rc1 File  Diff  Annotate