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