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

Overview

SmartGattLib

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

Implemented and tested characteristics

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

Compatibility

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

Integration

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 (SmartGattLib helps identifying the characteristics)
  6. Interpret the updates from the characteristics (SmartGattLib helps interpreting the data)

Example Android project with SmartGattLib available here. This is a fork of the Android BluetoothLeGatt Example project. Main modifications can be found in this commit.

Set up

  1. Add the JitPack repository and the dependency to your build file:
  repositories {
      maven { url "https://jitpack.io" }
  }
  dependencies {
      compile 'com.github.movisens:SmartGattLib:3.0'
  }

or download the latest .jar file from the releases page and place it in your Android app’s libs/ folder. 2. Use the example below to identifiy services and characteristics and interpret their data

Example Usage

import com.movisens.smartgattlib.*;
import com.movisens.smartgattlib.attributes.*;
import com.movisens.smartgattlib.helper.*;

// onConnected
// TODO: iterate over available services
UUID serviceUuid = null;// service.getUuid();
if (Services.HEART_RATE.getUuid().equals(serviceUuid)) {

    // TODO: iterate over characteristics
    UUID characteristicUuid = null;// characteristic.getUuid();
    if (Characteristics.HEART_RATE_MEASUREMENT.getUuid().equals(characteristicUuid)) {
        // TODO: Enable notification e.g. for Android API 18:
        // BluetoothGattDescriptor descriptor = characteristic.getDescriptor(Descriptor.CLIENT_CHARACTERISTIC_CONFIGURATION);
        // descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
        // mBluetoothGatt.writeDescriptor(descriptor);
    }
} else {
    System.out.println("Found unused Service: " + Services.lookup(serviceUuid));
}

// onCharacteristicChanged
UUID uuid = null;// characteristic.getUuid();
byte[] data = null;// characteristic.getValue();

AbstractAttribute a = Characteristics.lookup(uuid).createAttribute(data);
if (a instanceof HeartRateMeasurement) {
    HeartRateMeasurement heartRateMeasurement = ((HeartRateMeasurement) a);
    heartRateMeasurement.getHr();
    heartRateMeasurement.getEe();
} else if (a instanceof DefaultAttribute) {
    System.err.println("characteristic for " + uuid + " is unknown");
} else {
    System.out.println("unused characteristic " + a.getCharacteristic().getName());
}

// write Attribute
AbstractAttribute aa = new Weight(12.3);
// TODO: Write aa.getBytes() to aa.getCharacteristic().getUuid();

License

Copyright 2017 movisens GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • BLE Scan and Connection feature missing using Java program

    BLE Scan and Connection feature missing using Java program

    Is this feature can be implemented using JAVA program which is present for android and ios but not for desktop based app?

    1- Scan for devices 2- Connect to a GATT device

    BlueCove is a Java library for Bluetooth, for MsWindows, Mac OSX and others.

    but it seems that it does not support Bluetooth Low Enegry 4.0.

    Android has a standard Java library for Bluetooth LE 4.0: http://developer.android.com/guide/topics/connectivity/bluetooth.html

    Is this Java library can be supportable for Bluetooth LE 4.0 for MsWindows and/or Mac OSX?

    opened by ashishbhandari 3
  • Cool Project, More Examples?

    Cool Project, More Examples?

    Hi. This project looks really cool. after looking at the readme and Example.java. https://github.com/movisens/SmartGattLib/blob/master/src/main/java/com/movisens/smartgattlib/Example.java

    I don't quite understand the setup. I'm wondering if you could add a bit more detail to make the usage example complete.

    opened by cmrockwell 2
  • Added osgibnd plugin to generate OSGI metadata

    Added osgibnd plugin to generate OSGI metadata

    Added osgibnd plugin to the build to generate relevant OSGI metadata fields in the final MANIFEST.MF file. Added also a version property to explicitly set the project version both in the final jar filename and in the OSGI metadata.

    opened by IOOOTAlan 1
  • Cycling speed cadence sensor

    Cycling speed cadence sensor

    Used to measure speed and cadence from a cycling sensor

    Spec can be found here https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.csc_measurement.xml

    Let me know if I need to change formatting or anything like that. Thanks for the great library!

    opened by zsiegel 1
  • Java SE (BlueCove)

    Java SE (BlueCove)

    Hello,

    I would like to use your library to communicate with a Bluetooth LE device using Java SE (Desktop, not mobile), thank to a stack like BlueCove. Do you know if it is possible, and if yes, how?

    Thank you,

    Damien Raemy, School of Engineering and Architecture of Fribourg

    opened by damien-r 1
  • Change Build Script to Gradle

    Change Build Script to Gradle

    Example gradle script with maven deployment can be found here: http://yennicktrevels.com/blog/2013/10/11/automated-gradle-project-deployment-to-sonatype-oss-repository/

    opened by JStumpp 1
  • Host maven artifact in a repository like SonaType OSS or Maven Central

    Host maven artifact in a repository like SonaType OSS or Maven Central

    It would much easier to use this library if it was published to to a maven repository.

    You can read about how to do that here

    http://maven.apache.org/guides/mini/guide-central-repository-upload.html

    or here

    https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide

    If you are interested and need help let me know.

    opened by thoutbeckers 1
  • Exported packages (OSGi metadata)

    Exported packages (OSGi metadata)

    Hi, in the current build.gradle file the OSGi specific entries declare only one exported package, that is:

    'Export-Package': 'com.movisens.smartgattlib'

    This prevents the (OSGi) developer to reference some useful utilities like the "GattByteBuffer" class in the "com.movisens.smartgattlib.helper" package.

    I don't know if this is wanted or not, in the latter case you may consider to export all the packages within the main one, with a directive like the following:

    'Export-Package': 'com.movisens.smartgattlib, com.movisens.smartgattlib.*'

    Also an intermediate approach may be adopted, exporting only a subset of the packages: this is clearly up to you. Thanks.

    opened by IOOOTARobby 0
Releases(1.7)
Owner
movisens GmbH
movisens GmbH
[UNMAINTAINED][Android] Bluetooth Serial Port Profile which comfortable to developer application to communication with microcontroller via bluetooth

⚠ WARNING: This project is no longer being maintained Android-BluetoothSPPLibrary Bluetooth Serial Port Profile which comfortable to developer applica

Akexorcist 1.7k Dec 31, 2022
Smooth communication via bluetooth with other android devices or microcontrollers such as Arduino.

Android Smooth Bluetooth Smooth communication via bluetooth with other android devices or microcontrollers such as Arduino. Getting Started Add Gradle

Mantas Palaima 191 Nov 28, 2022
This library allows for easy access to a Bluetooth LE device's AdRecord and RSSI value. It offers additional functionality for iBeacons.

Bluetooth LE Library for Android This library allows for easy access to a Bluetooth LE device's Advertisement Records. It also offers: A simple runnin

Alexandros Schillings 843 Dec 13, 2022
A reactive, interface-driven central role Bluetooth LE library for Android

RxCentralBle RxCentralBle provides a simple reactive paradigm for connecting to and communicating with Bluetooth LE peripherals from the central role.

Uber Open Source 198 Nov 29, 2022
An Android Library for handling Bluetooth Low Energy on Android Easy

An Android Library for handling Bluetooth Low Energy on Android Easy

Leandro SQ 42 Jan 3, 2023
A Bluetooth kotlin multiplatform "Cross-Platform" library for iOS and Android

Blue-Falcon A Bluetooth "Cross Platform" Kotlin Multiplatform library for iOS, Android, MacOS, Raspberry Pi and Javascript. Bluetooth in general has t

Andrew Reed 220 Dec 28, 2022
An Android library that solves a lot of Android's Bluetooth Low Energy problems

A library that makes working with Bluetooth LE on Android a pleasure. Seriously.

Nordic Semiconductor 1.4k Jan 7, 2023
BLESSED Coroutines, a Bluetooth Low Energy (BLE) library for Android using Kotlin Coroutines

BLESSED for Android with Coroutines - BLE made easy BLESSED is a very compact Bluetooth Low Energy (BLE) library for Android 8 and higher, that makes

Martijn van Welie 82 Jan 1, 2023
Kotlin Asynchronous Bluetooth Low-Energy

Kable Kotlin Asynchronous Bluetooth Low Energy provides a simple Coroutines-powered API for interacting with Bluetooth Low Energy devices. Usage is de

JUUL Labs 493 Dec 25, 2022
A non-trivial Bluetooth LE app using Kable and app architecture best practices

kable_mvvm_demo The intention of this project is to demonstrate a non-trivial Bluetooth LE app using Kable and app architecture best practices. ⚠️ The

Chris Laplante 14 Aug 18, 2022
BluePass extracts two factor authentication codes (2FA) from SMS and sends them to a paired device via Bluetooth RFCOMM.

BluePass extracts two factor authentication codes (2FA) from SMS and sends them to a paired device via Bluetooth RFCOMM.

Manuel Huber 15 Dec 4, 2022
Open-source weight and body metrics tracker, with support for Bluetooth scales

Open-source weight and body metrics tracker, with support for Bluetooth scales

OliE 1.3k Jan 4, 2023
Simple bluetooth flutter project

bluetooth_simple Simple bluetooth implementation. Getting Started This project is a starting point for a Flutter application. A few resources to get y

Aleksey Vasiliev 0 Nov 25, 2021
The purpose is to share the Internet capability of one device to the entire Bluetooth LAN.

bluenet The purpose is to share the Internet capability of one device to the entire Bluetooth LAN. To make a prototype of a soft bus, or actually, I w

yunlong.wen 1 Jun 28, 2022
User-friendly Lightweight TPM Remote Attestation over Bluetooth

Ultrablue Ultrablue (User-friendly Lightweight TPM Remote Attestation over Bluetooth) is a solution to allow individual users to perform boot state at

ANSSI 32 Jan 2, 2023
RxBle: Use Android Bluetooth API in Rx way

RxBle: Use Android Bluetooth API in Rx way A lightweight encapsulation of Android Bluetooth API. Use Android Bluetooth API in Rx way. Support multiple

null 3 Dec 2, 2022
A simple, lightweight library intended to take away some of the cruft and tediousness of using the Android BLE.

Blueteeth What Is Blueteeth? Blueteeth is a simple, lightweight library intended to take away some of the cruft and tediousness of using the Android B

Robot Pajamas 103 Nov 26, 2022
This is a Bluetooth operational Chat-App developed using Kotlin which shows the list of available devices nearby and paired devices, upon clicking you can start chat

This is a Bluetooth operational Chat-App developed using Kotlin which shows the list of available devices nearby and paired devices, upon clicking you can start chat ... VOILA ???? It is still in its early stages of development and currently let user to one-time chat at a time. It is under heavy development ??

Shalu Ambasta 3 Jan 10, 2022
Android Bluetooth Helper Library, Bluetooth Device Finder

Bluetooth Helper Allows you to access the Bluetooth of your mobile device, manage turn-on - turn off, and discover bluetooth devices around you. Getti

Tolga Bolatcan 44 Jul 15, 2022
[UNMAINTAINED][Android] Bluetooth Serial Port Profile which comfortable to developer application to communication with microcontroller via bluetooth

⚠ WARNING: This project is no longer being maintained Android-BluetoothSPPLibrary Bluetooth Serial Port Profile which comfortable to developer applica

Akexorcist 1.7k Dec 31, 2022