Smart Fitness Bracelets are Android BLE (Bluetooth Low Energy) device that keeps a record of your step, distance and calorie, which can help you set your fitness goals per day, month or year with the help of its mobile application. It can also monitor your sleep. Fitbit, Garmin, and Polar are some of the brands that produce these bracelets.
This article will discuss the software components of a BLE Device and we’ll have a simple activity to access these components.
3 Main Software Components of BLE Device
Every BLE device has 3 main components preprogrammed inside its chip. It has a profile, services and characteristics. A profile, we call it GATT Profile (Generic Attribute Profile) is the container of all the services.
Below is the architecture of a GATT Profile :
Looking at the image above, a GATT has multiple services. A service contains multiple characteristics. So we can say the GATT is a collection of services and a service is a collection of characteristics.
The characteristic is where the actual values and information is presented. Security parameters, units and other metadata concerning the information are also encapsulated in the characteristics. Therefore, a service is a collection of information.
Services and characteristics are determined by UUIDs ( Universally Unique Identifier).
You need to get the UUID of a service for you to access the characteristic and UUID of the characteristic to access its values. For our Glucose Service example, it is under the Glucose Measurement characteristic we could get the amount of glucose in the blood that the Glucose BLE Device tested. But for some smart bracelets, like TW64, they have customized UUID’s for their services and characteristics. That is what we need to know. Therefore, for us to access the data recorded by the TW64 BLE Device, we need to know the customized UUIDs of all the services and characteristics… The below activity will get the list of all services and characteristics inside the GATT Profile of the device, either standard or customized.
For this activity we are going to use the ff:
- Installed Android Studio 1.3.X
- Installed Java Development Kit 7
- Installed GitBash
- Github Account
- Android BLE Sample from Github – https://github.com/googlesamples/android-BluetoothLeGatt.git
- TW64 Smart Bluetooth
- Android Phone (Kitkat)
STEP 1 : CLONE REPOSITORY OF ANDROID BLE SAMPLE FROM GITHUB
- Open GitBash.
- Type cd Desktop
- Type mkdir AndroidBLE
- Type cd AndroidBLE
- Type git clone https://github.com/googlesamples/android-BluetoothLeGatt.git
STEP 2 : OPEN PROJECT IN ANDROID STUDIO
- Open Android Studio
- Click File Tab.
- Import Project.
- Click Desktop Folder.
- Click AndroidBLE Folder.
- Click android-BluetoothLeGatt Project.
- Click Ok.
The project should look like the image below.
STEP 3 : Add FitnessMainActivity Class. You can download the FitnessMainActivity here.
STEP 4 : Run the app in your phone. You cannot use your emulator since it is not capable of any Bluetooth activities.
STEP 5 : Check the logs.
We can see that the displayGattServices method displays all the services and characteristics of our BLE device.
The log underlined in red are the services and enclosed in the green box are their characteristics.
The Generic Access, Generic Attribute, and Device Information are standard services under Bluetooth Organization. The remaining services which are ffe0 and fff0 are customized services that are preprogrammed by the manufacturer of the device.
That’s it. You already retrieved your BLE’s UUIDs. Your next step now is to get and parse the data coming from your BLE’s characteristics. Happy coding!