Git Product home page Git Product logo

android-ble-library's Introduction

Android BLE Library

This library has been extracted from nRF Toolbox project. It contains classes useful when doing a connection to a Bluetooth LE device.

Features

BleManager class provides the following features:

  1. Connection
  2. Service discovery
  3. Bonding (optional)
  4. Enabling Service Changed indications
  5. Device initialization
  6. Async BLE operations using queue
  7. Reading Battery Level value
  8. Requesting MTU and connection priority
  9. Error handling
  10. Logging (in LogCat and optionally nRF Logger)

It may be used for a single connection (see nRF Toolbox -> RSC profile) or when multiple connections are required (see nRF Toolbox -> Proximity profile), from a Service (see nRF Toolbox -> RSC profile), ViewModel's repo (see Architecture Components and nRF Blinky), or as a singleton (not recommended, see nRF Toolbox -> HRM).

BleManager exposes a high level API instead of low level BLE operations. If autoConnect option is to be used, the manager also handles initial connection (with autoConnect = false), which is much faster, and then reconnects in case of link loss with this parameter set to true. Just return true from shouldAutoConnect() method in your manager.

How to include it in your project

Clone this project and add ble module as a dependency to your project:

  1. In settings.gradle file add the following lines:
include ':ble'
project(':ble').projectDir = file('../Android-BLE-Library/ble')
  1. In app/build.gradle file add implementation project(':ble') inside dependencies.
  2. Sync project and build it

See example projects listed below.

How to use it

  1. Define your device API by extending BleManagerCallbacks: example
  2. Extend BleManager class and implement required methods: example

Example

Find the simple example here Android nRF Blinky.

For an example how to use it from an Activity or a Service, check the base Activity and Service classes in nRF Toolbox.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.