Exercise 3 Calzana-Iandiorio

Dependents:   BLELedScanner

Committer:
mcalzana
Date:
Thu Nov 29 18:13:44 2018 +0000
Revision:
0:c544827b6b11
Exercise 3

Who changed what in which revision?

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