Taeil Kim
/
color-firmware
king color
readme.md@0:d18ffa2b40b3, 2018-04-21 (annotated)
- Committer:
- LAINO
- Date:
- Sat Apr 21 08:25:59 2018 +0000
- Revision:
- 0:d18ffa2b40b3
mbed os firmware of color
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LAINO | 0:d18ffa2b40b3 | 1 | This example creates and updates a standard Battery Level service containing a single |
LAINO | 0:d18ffa2b40b3 | 2 | GATT characteristic. |
LAINO | 0:d18ffa2b40b3 | 3 | |
LAINO | 0:d18ffa2b40b3 | 4 | The [battery service transmits](https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml) a device's battery level in percentage, with 100% being a fully charged battery and 0% being a fully drained battery. |
LAINO | 0:d18ffa2b40b3 | 5 | |
LAINO | 0:d18ffa2b40b3 | 6 | Although the sample application runs on a BLE device, it doesn't show the device's real battery level (because that changes very slowly and will make for a dull example). Instead, it transmits a fake battery level that starts at 50% (half charged). Every half second, it increments the battery level, going in single increments until reaching 100% (as if the battery is charging). It then drops down to 20% to start incrementing again. |
LAINO | 0:d18ffa2b40b3 | 7 | |
LAINO | 0:d18ffa2b40b3 | 8 | # Running the application |
LAINO | 0:d18ffa2b40b3 | 9 | |
LAINO | 0:d18ffa2b40b3 | 10 | ## Requirements |
LAINO | 0:d18ffa2b40b3 | 11 | |
LAINO | 0:d18ffa2b40b3 | 12 | The sample application can be seen on any BLE scanner on a smartphone. If you don't have a scanner on your phone, please install : |
LAINO | 0:d18ffa2b40b3 | 13 | |
LAINO | 0:d18ffa2b40b3 | 14 | - [nRF Master Control Panel](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp) for Android. |
LAINO | 0:d18ffa2b40b3 | 15 | |
LAINO | 0:d18ffa2b40b3 | 16 | - [LightBlue](https://itunes.apple.com/gb/app/lightblue-bluetooth-low-energy/id557428110?mt=8) for iPhone. |
LAINO | 0:d18ffa2b40b3 | 17 | |
LAINO | 0:d18ffa2b40b3 | 18 | Hardware requirements are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md). |
LAINO | 0:d18ffa2b40b3 | 19 | |
LAINO | 0:d18ffa2b40b3 | 20 | ## Building instructions |
LAINO | 0:d18ffa2b40b3 | 21 | |
LAINO | 0:d18ffa2b40b3 | 22 | Building instructions for all samples are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md). |
LAINO | 0:d18ffa2b40b3 | 23 | |
LAINO | 0:d18ffa2b40b3 | 24 | ## Checking for success |
LAINO | 0:d18ffa2b40b3 | 25 | |
LAINO | 0:d18ffa2b40b3 | 26 | **Note:** Screens captures depicted below show what is expected from this example if the scanner used is *nRF Master Control Panel* version 4.0.5. If you encounter any difficulties consider trying another scanner or another version of nRF Master Control Panel. Alternative scanners may require reference to their manuals. |
LAINO | 0:d18ffa2b40b3 | 27 | |
LAINO | 0:d18ffa2b40b3 | 28 | 1. Build the application and install it on your board as explained in the building instructions. |
LAINO | 0:d18ffa2b40b3 | 29 | 1. Open the BLE scanner on your phone. |
LAINO | 0:d18ffa2b40b3 | 30 | 1. Start a scan. |
LAINO | 0:d18ffa2b40b3 | 31 | |
LAINO | 0:d18ffa2b40b3 | 32 | ![](img/start_scan.png) |
LAINO | 0:d18ffa2b40b3 | 33 | |
LAINO | 0:d18ffa2b40b3 | 34 | **figure 1** How to start scan using nRF Master Control Panel 4.0.5 |
LAINO | 0:d18ffa2b40b3 | 35 | |
LAINO | 0:d18ffa2b40b3 | 36 | 1. Find your device; it should be named `BATTERY`. |
LAINO | 0:d18ffa2b40b3 | 37 | |
LAINO | 0:d18ffa2b40b3 | 38 | ![](img/scan_result.png) |
LAINO | 0:d18ffa2b40b3 | 39 | |
LAINO | 0:d18ffa2b40b3 | 40 | **figure 2** Scan results using nRF Master Control Panel 4.0.5 |
LAINO | 0:d18ffa2b40b3 | 41 | |
LAINO | 0:d18ffa2b40b3 | 42 | 1. Establish a connection with your device. |
LAINO | 0:d18ffa2b40b3 | 43 | |
LAINO | 0:d18ffa2b40b3 | 44 | ![](img/connection.png) |
LAINO | 0:d18ffa2b40b3 | 45 | |
LAINO | 0:d18ffa2b40b3 | 46 | **figure 3** How to establish a connection using Master Control Panel 4.0.5 |
LAINO | 0:d18ffa2b40b3 | 47 | |
LAINO | 0:d18ffa2b40b3 | 48 | 1. Discover the services and the characteristics on the device. The *Battery service* has the UUID 0x180F and includes the *Battery level* characteristic which has the UUID 0x2A19. |
LAINO | 0:d18ffa2b40b3 | 49 | |
LAINO | 0:d18ffa2b40b3 | 50 | ![](img/discovery.png) |
LAINO | 0:d18ffa2b40b3 | 51 | |
LAINO | 0:d18ffa2b40b3 | 52 | **figure 4** Representation of the Battery service using Master Control Panel 4.0.5 |
LAINO | 0:d18ffa2b40b3 | 53 | |
LAINO | 0:d18ffa2b40b3 | 54 | 1. Register for the notifications sent by the *Battery level* characteristic. |
LAINO | 0:d18ffa2b40b3 | 55 | |
LAINO | 0:d18ffa2b40b3 | 56 | ![](img/register_to_notifications.png) |
LAINO | 0:d18ffa2b40b3 | 57 | |
LAINO | 0:d18ffa2b40b3 | 58 | **figure 5** How to register to notifications using Master Control Panel 4.0.5 |
LAINO | 0:d18ffa2b40b3 | 59 | |
LAINO | 0:d18ffa2b40b3 | 60 | |
LAINO | 0:d18ffa2b40b3 | 61 | 1. You should see the battery level value change every half second. It begins at 50, goes up to 100 (in steps of 1), resets to 20 and so on. |
LAINO | 0:d18ffa2b40b3 | 62 | |
LAINO | 0:d18ffa2b40b3 | 63 | ![](img/notifications.png) |
LAINO | 0:d18ffa2b40b3 | 64 | |
LAINO | 0:d18ffa2b40b3 | 65 | **figure 6** Notifications view using Master Control Panel 4.0.5 |
LAINO | 0:d18ffa2b40b3 | 66 | |
LAINO | 0:d18ffa2b40b3 | 67 | If you can see the characteristic, and if its value is incrementing correctly, the application is working properly. |
LAINO | 0:d18ffa2b40b3 | 68 |