Skip to content

SmartGattLib is a Java library that simplifies the work with Bluetooth SMART devices

Notifications You must be signed in to change notification settings

movisens/SmartGattLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SmartGattLib

SmartGattLib is a Java library that simplifies the work with Bluetooth SMART devices. It provides all UUIDs of the adopted GATT specification and an convenient way to interpret the characteristics (e.g. Heart Rate, BatteryLevel).

Currently implemented and tested characteristics:

  • BatteryLevel
  • BodySensorLocation
  • HeartRateMeasurement
  • ManufacturerNameString
  • More to come. Please commit pull request to add more characteristics.

The library has no dependencies and can be use with every Bluetooth SMART stack e.g.:

Working with Bluetooth SMART devices is usually done in the following way:

  1. Scan for devices
  2. Connect to a GATT device
  3. Discover services
  4. Get characteristics for the services of interest (SmartGattLib helps identifying the services)
  5. Read characteristics or register for updates of the characteristics (SmartGattLib helps identifying the characteristics)
  6. Interpret the updates from the characteristics (SmartGattLib helps interpreting the data)

Set up

  1. Drop the SmartGittLib-0.1.jar to the libs folder of your Android project.
  2. Use the example below to identifiy services and characteristics and interpret their data

Example Usage

// onConnected
//TODO: iterate over available services
UUID serviceUuid = service.getUuid();
if (Service.HEART_RATE.equals(serviceUuid)) {
	
	//TODO: iterate over characteristics
	UUID characteristicUuid = characteristic.getUuid();
	if (Characteristic.HEART_RATE_MEASUREMENT.equals(characteristicUuid)) {
		// TODO: Enable notification
	}
}

// onCharacteristicChanged
UUID characteristicUuid = characteristic.getUuid();
if (Characteristic.HEART_RATE_MEASUREMENT.equals(characteristicUuid)) {
	byte[] value = characteristic.getValue();
	HeartRateMeasurement hrm = new HeartRateMeasurement(value);
	hrm.getHr();
	hrm.getEe();
}

About

SmartGattLib is a Java library that simplifies the work with Bluetooth SMART devices

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages