Bluetooth

Committer:
ackerden
Date:
Mon Apr 26 13:45:48 2021 +0000
Revision:
1:cf0602e9d9df
Parent:
0:7373a1c9d5b4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apalmieri 0:7373a1c9d5b4 1 This example shows how to advertise a value of battery service data. The battery value is simulated.
apalmieri 0:7373a1c9d5b4 2 The battery level is a percentage, with 100% being a fully charged battery and 0% being a fully drained battery.
apalmieri 0:7373a1c9d5b4 3 The level starts at 50% and drains every second second, until it hits 10% when it jumps to 100% and continues draining.
apalmieri 0:7373a1c9d5b4 4
apalmieri 0:7373a1c9d5b4 5 # Running the application
apalmieri 0:7373a1c9d5b4 6
apalmieri 0:7373a1c9d5b4 7 ## Requirements
apalmieri 0:7373a1c9d5b4 8
apalmieri 0:7373a1c9d5b4 9 Hardware requirements are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md).
apalmieri 0:7373a1c9d5b4 10
apalmieri 0:7373a1c9d5b4 11 ## Building instructions
apalmieri 0:7373a1c9d5b4 12
apalmieri 0:7373a1c9d5b4 13 Building instructions for all samples are in the [main readme](https://github.com/ARMmbed/mbed-os-example-ble/blob/master/README.md).
apalmieri 0:7373a1c9d5b4 14
apalmieri 0:7373a1c9d5b4 15 ## Checking for success
apalmieri 0:7373a1c9d5b4 16
apalmieri 0:7373a1c9d5b4 17 **Note:** Screens captures depicted below show what is expected from this example if the scanner used is *nRF Connect for Mobile* version 4.0.5. If you encounter any difficulties consider trying another scanner or another version of nRF Connect for Mobile. Alternative scanners may require reference to their manuals.
apalmieri 0:7373a1c9d5b4 18
apalmieri 0:7373a1c9d5b4 19 1. Build the application and install it on your board as explained in the building instructions.
apalmieri 0:7373a1c9d5b4 20 1. Open the BLE scanner on your phone.
apalmieri 0:7373a1c9d5b4 21 1. Start a scan.
apalmieri 0:7373a1c9d5b4 22
apalmieri 0:7373a1c9d5b4 23 ![](img/start_scan.png)
apalmieri 0:7373a1c9d5b4 24
apalmieri 0:7373a1c9d5b4 25 **figure 1** How to start scan using nRF Connect for Mobile 4.0.5
apalmieri 0:7373a1c9d5b4 26
apalmieri 0:7373a1c9d5b4 27 1. Find your device; it should be named `BATTERY`.
apalmieri 0:7373a1c9d5b4 28
apalmieri 0:7373a1c9d5b4 29 ![](img/scan_result.png)
apalmieri 0:7373a1c9d5b4 30
apalmieri 0:7373a1c9d5b4 31 **figure 2** Scan results using nRF Connect for Mobile 4.0.5
apalmieri 0:7373a1c9d5b4 32
apalmieri 0:7373a1c9d5b4 33 1. Click on the entry to see the payload details
apalmieri 0:7373a1c9d5b4 34
apalmieri 0:7373a1c9d5b4 35
apalmieri 0:7373a1c9d5b4 36 If you can see the battery level, and if its value is changing, the application is working properly.
apalmieri 0:7373a1c9d5b4 37