All Projects → Belolme → Rxble

Belolme / Rxble

使用 RxJava 封装的低功耗蓝牙类库

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxble

Reactivebeacons
Android library scanning BLE beacons nearby with RxJava
Stars: ✭ 171 (-15.76%)
Mutual labels:  rxjava, rxjava2, ble, bluetooth-low-energy
Rxandroidble
An Android Bluetooth Low Energy (BLE) Library with RxJava2 interface
Stars: ✭ 3,025 (+1390.15%)
Mutual labels:  rxjava, rxjava2, ble, bluetooth-low-energy
Rxbluetoothkotlin
Bluetooth low energy reactive framework for Android written in Kotlin
Stars: ✭ 68 (-66.5%)
Mutual labels:  rxjava, ble, bluetooth-low-energy
Rxwear
⌚️ Reactive Wearable API Library for Android and RxJava
Stars: ✭ 163 (-19.7%)
Mutual labels:  rxjava, rxjava2
Node Ble
Bluetooth Low Energy (BLE) library written with pure Node.js (no bindings) - baked by Bluez via DBus
Stars: ✭ 159 (-21.67%)
Mutual labels:  ble, bluetooth-low-energy
Reactivesensors
Android library monitoring device hardware sensors with RxJava
Stars: ✭ 161 (-20.69%)
Mutual labels:  rxjava, rxjava2
Dagger2
Kotlin Dagger2 example project
Stars: ✭ 145 (-28.57%)
Mutual labels:  rxjava, rxjava2
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (-13.79%)
Mutual labels:  rxjava, rxjava2
H Ble
Android Ble类库,基于回调,暴露搜索、连接、发送、接收、断开连接等接口,无需关心细节操作即可进行Ble通信。
Stars: ✭ 171 (-15.76%)
Mutual labels:  ble, bluetooth-low-energy
Disposer
Easily dispose rxJava streams with Android's Lifecycle
Stars: ✭ 176 (-13.3%)
Mutual labels:  rxjava, rxjava2
Httprequest
基于Retrofit2+RxJava2+OkHttp3的网络请求框架,可以完美的应用到组件化、MVP模式等项目中
Stars: ✭ 181 (-10.84%)
Mutual labels:  rxjava, rxjava2
Easyble
Android BLE framework
Stars: ✭ 155 (-23.65%)
Mutual labels:  ble, bluetooth-low-energy
Jd Mall Master
一款高仿京东商城的UI,基于MVP的Retrofit2(okhttp3)+rxjava+dagger2+greendao+glide。该项目系仿京东商城,属于独立开发者作品,仅供参考学习,拒绝做一切商业用途,如有侵权,请告知删除
Stars: ✭ 151 (-25.62%)
Mutual labels:  rxjava, rxjava2
Reactivewifi
Android library listening available WiFi Access Points and related information with RxJava Observables
Stars: ✭ 186 (-8.37%)
Mutual labels:  rxjava, rxjava2
Android Developer Roadmap
Android Developer Roadmap - A complete roadmap to learn Android App Development
Stars: ✭ 2,170 (+968.97%)
Mutual labels:  rxjava, rxjava2
Continuity
Apple Continuity Protocol Reverse Engineering and Dissector
Stars: ✭ 180 (-11.33%)
Mutual labels:  ble, bluetooth-low-energy
Blessed Android
BLESSED, a Bluetooth Low Energy (BLE) library for Android
Stars: ✭ 195 (-3.94%)
Mutual labels:  ble, bluetooth-low-energy
Rxpermission
Reactive permissions for Android
Stars: ✭ 182 (-10.34%)
Mutual labels:  rxjava, rxjava2
Rxjavapriorityscheduler
RxPS - RxJavaPriorityScheduler - A RxJava Priority Scheduler library for Android and Java applications
Stars: ✭ 138 (-32.02%)
Mutual labels:  rxjava, rxjava2
Android Clean Architecture Boilerplate
Apply clean architecture on Android
Stars: ✭ 141 (-30.54%)
Mutual labels:  rxjava, rxjava2

RxBLE

这是一个使用 RxJava 封装的低功耗蓝牙类库。封装了低功耗蓝牙的连接,写入数据,读取数据和监听硬件特定通道数据改变的功能。关于低功耗蓝牙的入门介绍可以参阅 我的简书博客

使用方法

clone 下来,复制 ble 包到本地项目即可使用(确保当前开发的项目有依赖 RxJava2)。可根据自己的需求进行二次开发。

初始化蓝牙

BluetoothClient mClient;

mClient = new BluetoothClientBLEV2Adapter(
	BluetoothLeInitialization.getInstance(this));
mClient.openBluetooth();

扫描设备

        // 第一参数指定扫描时间,第二个参数指定是否中断当前正在进行的扫描操作
        mClient.search(3000, false)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<BLEDevice>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        mTextView.setText("start\n");
                    }

                    @Override
                    public void onNext(BLEDevice value) {
                        Log.d(TAG, "device " + value);
                        mTextView.setText(mTextView.getText() + "\n\n" + value);
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "onError: ", e);
                        mTextView.setText(mTextView.getText() + "\n\n" + "complete");
                    }

                    @Override
                    public void onComplete() {
                        Log.d(TAG, "onComplete: search");
                        mTextView.setText(mTextView.getText() + "\n\n" + "complete");
                    }
                });
    }

连接并写入数据示例

    private void connectAndWrite() {
        mClient.connect(MAC[1])
                .flatMap(new Function<String, ObservableSource<String>>() {
                    @Override
                    public ObservableSource<String> apply(String s) throws Exception {
                        Log.d(TAG, "connect test: on write");
                        return mClient.write(MAC[1], UUID_SERVICE_CHANNEL,
                                UUID_CHARACTERISTIC_CHANNEL, "01234567876543210#".getBytes());
                    }
                })
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        Log.d(TAG, "connect test onSubscribe: ");
                    }

                    @Override
                    public void onNext(String value) {
                        Log.d(TAG, "connect test onNext: ");
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "connect test onError: ", e);
                    }

                    @Override
                    public void onComplete() {
                        Log.d(TAG, "connect test onComplete: ");
                    }
                });
    }

连接并设置蓝牙特定通道数据的监听

mClient.connect(MAC[1])
        .flatMap(new Function<String, ObservableSource<String>>() {
            @Override
            public ObservableSource<String> apply(String s) throws Exception {
                return mClient.registerNotify(MAC[1], UUID_SERVICE_CHANNEL,
                        UUID_CHARACTERISTIC_CHANNEL, new BaseResultCallback<byte[]>() {
                            @Override
                            public void onSuccess(byte[] data) {
                                Log.d(TAG, "I have receive a new message: "
                                        + Arrays.toString(data));
                            }

                            @Override
                            public void onFail(String msg) {
                                Log.d(TAG, "oop! setting register is failed!");
                            }
                        });
            }
        })
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].