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

Committer:
mbed_official
Date:
Thu Jul 28 23:14:52 2016 +0100
Revision:
2:3f5a4729c22b
Parent:
0:86bf1d2040b3
Merge branch 'master' of https://github.com/ARMmbed/mbed-os-example-ble


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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 2:3f5a4729c22b 1 # BLE LED Blinker
mbed_official 2:3f5a4729c22b 2
mbed_official 2:3f5a4729c22b 3 This example demonstrates using the ``GattClient`` API to control BLE client devices.
mbed_official 2:3f5a4729c22b 4
mbed_official 2:3f5a4729c22b 5 The example uses two applications running on two different devices:
mbed_official 2:3f5a4729c22b 6
mbed_official 2:3f5a4729c22b 7 1. The first device - the central - runs the application ``BLE_LEDBlinker`` from this repository. This application sends an on/off toggle over BLE.
mbed_official 2:3f5a4729c22b 8
mbed_official 2:3f5a4729c22b 9 1. The second device - the peripheral - runs the application [``BLE_LED``](https://github.com/ARMmbed/mbed-os-example-ble/tree/master/BLE_LED) to respond to the toggle.
mbed_official 2:3f5a4729c22b 10
mbed_official 2:3f5a4729c22b 11 The toggle simply turns the LED on the peripheral device on and off.
mbed_official 2:3f5a4729c22b 12
mbed_official 2:3f5a4729c22b 13 # Running the application
mbed_official 2:3f5a4729c22b 14
mbed_official 2:3f5a4729c22b 15 ## Requirements
mbed_official 2:3f5a4729c22b 16
mbed_official 2:3f5a4729c22b 17 Hardware requirements are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md).
mbed_official 2:3f5a4729c22b 18
mbed_official 2:3f5a4729c22b 19 This example requires *two* devices.
mbed_official 2:3f5a4729c22b 20
mbed_official 2:3f5a4729c22b 21 ## Building instructions
mbed_official 2:3f5a4729c22b 22
mbed_official 2:3f5a4729c22b 23 You will need to build both applications and flash each one to a different board.
mbed_official 2:3f5a4729c22b 24
mbed_official 2:3f5a4729c22b 25 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` advertise "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`.
mbed_official 2:3f5a4729c22b 26
mbed_official 2:3f5a4729c22b 27 **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``.
mbed_official 2:3f5a4729c22b 28
mbed_official 2:3f5a4729c22b 29 Building instructions for all mbed OS samples are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md).
mbed_official 2:3f5a4729c22b 30
mbed_official 2:3f5a4729c22b 31 ## Checking for success
mbed_official 2:3f5a4729c22b 32
mbed_official 2:3f5a4729c22b 33 1. Build both applications and install one on each device, as explained in the building instructions.
mbed_official 2:3f5a4729c22b 34
mbed_official 2:3f5a4729c22b 35 1. The LED number two of the device running ``BLE_LED`` should blink.
mbed_official 2:3f5a4729c22b 36
mbed_official 2:3f5a4729c22b 37
mbed_official 2:3f5a4729c22b 38 ## Monitoring the application through a serial port
mbed_official 2:3f5a4729c22b 39
mbed_official 2:3f5a4729c22b 40 You can run ``BLE_LEDBlinker`` and see that it works properly by monitoring its serial output.
mbed_official 2:3f5a4729c22b 41
mbed_official 2:3f5a4729c22b 42 You need a terminal program to listen to the output through a serial port. You can download one, for example:
mbed_official 2:3f5a4729c22b 43
mbed_official 2:3f5a4729c22b 44 * Tera Term for Windows.
mbed_official 2:3f5a4729c22b 45 * CoolTerm for Mac OS X.
mbed_official 2:3f5a4729c22b 46 * GNU Screen for Linux.
mbed_official 2:3f5a4729c22b 47
mbed_official 2:3f5a4729c22b 48 To see the application's output:
mbed_official 2:3f5a4729c22b 49
mbed_official 2:3f5a4729c22b 50 1. Check which serial port your device is connected to.
mbed_official 2:3f5a4729c22b 51 1. 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``.
mbed_official 2:3f5a4729c22b 52 1. The application should start printing the toggle's value to the terminal.
mbed_official 2:3f5a4729c22b 53
mbed_official 2:3f5a4729c22b 54 **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.