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