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