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.

Changes

RevisionDateWhoCommit message
81:653db77bffd4 2019-08-15 mbed_official Merge pull request #252 from donatieng/mbed_os_update default tip
80:a1604e77ee53 2019-02-27 mbed_official Updating mbed-os to mbed-os-5.11.5
79:5cf4b6fa98e9 2019-02-25 mbed_official Merge pull request #217 from adbridge/master
78:a506bcec15f7 2019-02-13 mbed_official Updating mbed-os to mbed-os-5.11.2
77:85a0d3cdd896 2019-01-25 mbed_official Fix SafeEnum comparison.
76:529e11f27d42 2019-01-14 mbed_official Merge pull request #207 from adbridge/master
75:1a8d19363522 2019-01-14 mbed_official Merge pull request #208 from ARMmbed/mbed-os-5.11.0-oob
74:9fe38e799fb7 2018-12-14 mbed_official Updating mbed-os to mbed-os-5.10.4
73:a03792f7d1d0 2018-11-16 mbed_official Merge pull request #192 from paul-szczepanek-arm/update-libs
72:fb3c62a2d071 2018-11-07 mbed_official Merge pull request #189 from ARMmbed/donatieng-patch-1
71:20963f2084bc 2018-10-22 mbed_official Merge pull request #187 from cmonr/master
70:d538baadec67 2018-09-26 mbed_official Merge pull request #183 from ARMmbed/mbed-os-5.10.0-oob
69:fddbf0cf8e2c 2018-09-04 mbed_official Merge pull request #173 from pan-/use-cordio
68:b2a432a5ed6c 2018-08-29 mbed_official Merge pull request #172 from 0xc0170/master
67:44c2f50cd682 2018-08-23 mbed_official Updating mbed-os to mbed-os-5.9.5
66:c7215fbbaecf 2018-08-08 mbed_official Merge pull request #168 from cmonr/master
65:22e2694558fa 2018-07-18 mbed_official Merge pull request #166 from cmonr/master
64:a1a0f49da527 2018-07-06 mbed_official Merge pull request #163 from adbridge/master
63:a52d6f200685 2018-06-22 mbed_official Merge pull request #160 from adbridge/master
62:cd21056d9f29 2018-06-20 mbed_official Merge pull request #159 from ARMmbed/mbed-os-5.9.0-oob
61:d177976f316d 2018-06-11 mbed_official Merge pull request #158 from adbridge/master
60:9c67aa8caa55 2018-06-05 mbed_official Merge pull request #151 from paul-szczepanek-arm/privacy
59:10e5712dbd00 2018-04-04 mbed_official Merge pull request #141 from adbridge/master
58:bb0f8b685b1e 2018-04-04 mbed_official Merge pull request #142 from ARMmbed/mbed-os-5.8.0-oob
57:b120532a40ab 2018-03-23 mbed_official Merge pull request #139 from cmonr/master
56:94aea6265896 2018-03-23 mbed_official Merge pull request #137 from adbridge/master
55:7a79c842cef1 2018-02-13 mbed_official Merge pull request #135 from adbridge/master
54:ab515dbbb801 2018-01-31 mbed_official Merge pull request #134 from cmonr/master
53:bf9a45219fe2 2018-01-17 mbed_official Merge pull request #133 from adbridge/master
52:797fc620e4d2 2018-01-09 mbed_official Merge pull request #129 from adbridge/master
51:a2d13f73fcf0 2018-01-08 mbed_official Merge pull request #132 from pan-/remove-mbedignore
50:edaaab61d692 2017-12-20 mbed_official Merge pull request #126 from ARMmbed/mbed-os-5.7.0-oob
49:2fe76892ad76 2017-12-05 mbed_official Merge pull request #119 from adbridge/master
48:cb1d091fad7d 2017-11-23 mbed_official Merge pull request #115 from adbridge/master
47:920438061d32 2017-11-07 mbed_official Merge pull request #113 from adbridge/master
46:5317d0d02e0f 2017-11-03 mbed_official Merge pull request #110 from 0xc0170/master
45:9fe6d1e21b8a 2017-11-01 mbed_official Merge pull request #112 from marcbonnici/master
44:1ef876d2a049 2017-10-11 mbed_official Merge pull request #108 from adbridge/master
43:aa4eca84d71a 2017-09-29 mbed_official Merge pull request #106 from 0xc0170/master
42:59bdc0cf8b36 2017-09-20 mbed_official Merge pull request #103 from ARMmbed/5.6_sanity
41:23b05cc8a158 2017-09-08 mbed_official Merge pull request #102 from adbridge/master
40:38475206d9c9 2017-08-08 mbed_official Merge pull request #100 from 0xc0170/master
39:dd468c8a4277 2017-07-28 mbed_official Merge pull request #99 from bcostm/add_disco_l475vg
38:ed69923f4965 2017-07-19 mbed_official Merge pull request #97 from 0xc0170/master
37:b22923de1261 2017-07-19 mbed_official Merge pull request #98 from apalmieriGH/master
36:c22b5f6d32b4 2017-07-11 mbed_official Merge pull request #93 from adbridge/master
35:947ef4c45474 2017-06-22 mbed_official Merge pull request #89 from adbridge/master
34:d910e1496ec9 2017-06-22 mbed_official Merge pull request #90 from apalmieriGH/master
33:7e92b7625efa 2017-06-20 mbed_official Merge pull request #88 from adbridge/master
32:976ba5aad0c1 2017-06-15 mbed_official Merge pull request #83 from apalmieriGH/master
31:7e8fbd60a611 2017-06-08 mbed_official Merge pull request #82 from adbridge/master
30:dd9909a5bf02 2017-05-25 mbed_official Merge pull request #81 from adbridge/master
29:628273dfb8f8 2017-05-10 mbed_official Merge pull request #79 from adbridge/master
28:64621b6587e1 2017-05-10 mbed_official Merge pull request #78 from ashok-rao/master
27:9fde1d0514c1 2017-05-09 mbed_official Merge pull request #77 from 0xc0170/master
26:6be3dcdca4ea 2017-04-05 mbed_official Merge pull request #70 from 0xc0170/master
25:5ab72b6c4510 2017-04-05 mbed_official Merge pull request #72 from pan-/update_bluenrg_ref
24:aecc41e63fa4 2017-04-05 mbed_official Merge pull request #71 from pan-/fix_bluenrg_reference
23:27f72f0c8c26 2017-03-14 mbed_official Merge pull request #68 from adbridge/master
22:290659788ea9 2017-03-09 mbed_official Merge pull request #66 from ARMmbed/oob_test_mbed-os-5.4