Project Url: uber/RxCentralBle
Introduction: A reactive, interface-driven central role Bluetooth LE library for Android
More: Author   ReportBugs   

RxCentralBle is a reactive, interface-driven library used to integrate with Bluetooth LE peripherals.

For those tired of writing eerily similar, yet subtly different code for every Bluetooth LE peripheral integration, RxCentralBle provides a standardized, simple reactive paradigm for connecting to and communicating with peripherals from the central role.

Check out our detailed Wiki for designs and examples for all the capabilities of RxCentralBle.

Key Features

  • Reactive; observe actions to trigger them, dispose to stop.
  • Built-in operation queue; respects the serial nature of Android's BluetoothGatt.
  • Interface-driven; customize the library with your own implementations
  • Manager-based; two managers for all connectivity and communication


RxCentralBle optimizes for the following use cases:

  • Where the ability to connect to and communicate with a Bluetooth LE peripheral is needed
  • Where the peripheral is Bluetooth 4.0 LE compliant and acts per the specification
  • Where the peripheral does not require Bluetooth 4.0 specified authentication
  • Where the peripheral is not an ultra-low power device


Available on Maven Central:

dependencies {
  implementation 'com.uber.rxcentralble:rx-central-ble:1.2.0'


The below demonstrates simple usage of RxCentralBle. Check out the Wiki for details!

Bluetooth Detection

Use the BluetoothDetector to detect the state of Bluetooth:

BluetoothDetector bluetoothDetector;
Disposable detection;

// Use the detector to detect Bluetooth state.
detection = bluetoothDetector
       enabled -> {
         // Tell the user to turn on Bluetooth if not enabled

Dispose of your subscription to stop detection.

// Stop Bluetooth detection.

Connection Management

Use the ConnectionManager to manage the lifecycle of connections to a peripheral and supply a fresh Peripheral to the PeripheralManager on every connection.

ScanMatcher scanMatcher;
ConnectionManager connectionManager;
PeripheralManager peripheralManager;
Disposable connection

// Connect to a peripheral.  
connection = connectionManager
        peripheral -> {
          // Inject the latest connected Periphearl into your PeripheralManager.
        error -> {
          // Connection lost.

Dispose of your subscription to disconnect.

// Disconnect.

Peripheral Management

After injecting the connected Peripheral into your PeripheralManager, you can then queue operations and the PeripheralManager will ensure these are executed in a serial FIFO fashion. The PeripheralManager is thread safe, so multiple consuming threads can queue operations and they will be reliably executed in the order they are subscribed.

PeripheralManager peripheralManager;
Write write;
Disposable queued;

// Queue a write operaiton.
queued = peripheralManager
       irrelevant -> {
         // Write was successful.
       error -> {
         // Write failed.

Dispose of your subscription to dequeue (i.e. cancel).

// Cancel the write operation if it hasn't begun execution.

Sample App

The included sample application allows you to connect to any Bluetooth LE peripheral by name and query the Generic Access, Device Information, and Battery services. Feel free to improve upon the sample and submit PRs to help the RxCentralBle community.


Copyright (C) 2018 Uber Technologies

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


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
About Me
Google+: Trinea trinea
GitHub: Trinea