Promisified BLE library for Android.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bletia-core
bletia
gradle/wrapper
rxbletia
samples
.gitignore
LICENSE.md
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle
wercker.yml

README.md

Bletia / RxBletia

wercker status LICENSE Download

  • Bletia: Promisified BluetoothGatt wrapper library(including JDeferred)
  • RxBletia: RxJava binding APIs for Android's BluetoothGatt

Download

Use Bletia:

dependencies {
    // use Bletia
    compile 'info.izumin.android:bletia:2.0.0'
}

Use RxBletia:

dependencies {
    // use RxBletia
    compile 'info.izumin.android:bletia:2.0.0'
    compile 'io.reactivex:rxjava:1.0.16'
}

Quick Examples

Instantiate

// Pass application context to constructor.
Bletia bletia = new Bletia(context);

Connect to BLE device

// BluetoothDevice device
bletia.connect(device);

Enable notification

// BluetoothGattCharacteristic characteristic 
bletia.enableNotification(characteristic, true)
    .then(new DoneCallback<BluetoothGattCharacteristic>() {
        @Override
        public void onDone(BluetoothGattCharacteristic result) {
            // Call when the request was successfully.
        }
    })
    .fail(new FailCallback<BletiaException>() {
        @OVerride
        public void onFail(BletiaException result) {
            // Call when the request was failure.
        }
    });

Read characteristic

// BluetoothGattCharacteristic characteristic 
bletia.readCharacteristic(characteristic)
    .then(new DoneCallback<BluetoothGattCharacteristic>() {
        @Override
        public void onDone(BluetoothGattCharacteristic result) {
            // Call when the request was successfully.
        }
    })
    .fail(new FailCallback<BletiaException>() {
        @OVerride
        public void onFail(BletiaException result) {
            // Call when the request was failure.
        }
    });

Write characteristic

// BluetoothGattCharacteristic characteristic
bletia.writeCharacteristic(characteristic)
    .then(new DoneCallback<BluetoothGattCharacteristic>() {
        @Override
        public void onDone(BluetoothGattCharacteristic result) {
            // Call when the request was successfully.
        }
    })
    .fail(new FailCallback<BletiaException>() {
        @OVerride
        public void onFail(BletiaException result) {
            // Call when the request was failure.
        }
    });

Read descriptor

// BluetoothGattDescriptor descriptor
bletia.readDescriptor(descriptor)
    .then(new DoneCallback<BluetoothGattDescriptor>() {
        @Override
        public void onDone(BluetoothGattDescriptor result) {
            // Call when the request was successfully.
        }
    })
    .fail(new FailCallback<BletiaException>() {
        @OVerride
        public void onFail(BletiaException result) {
            // Call when the request was failure.
        }
    });

Write descriptor

// BluetoothGattDescriptor descriptor
bletia.writeDescriptor(descriptor)
    .then(new DoneCallback<BluetoothGattDescriptor>() {
        @Override
        public void onDone(BluetoothGattDescriptor result) {
            // Call when the request was successfully.
        }
    })
    .fail(new FailCallback<BletiaException>() {
        @OVerride
        public void onFail(BletiaException result) {
            // Call when the request was failure.
        }
    });

Read remote RSSI

bletia.readRemoteRssi()
    .then(new DoneCallback<Integer>() {
        @Override
        public void onDone(Integer result) {
            // Call when the request was successfully.
        }
    })
    .fail(new FailCallback<BletiaException>() {
        @OVerride
        public void onFail(BletiaException result) {
            // Call when the request was failure.
        }
    });

Sample

License

Copyright 2015 izumin5210

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.