RxAndroidBle | Android Bluetooth Low Energy Library with RxJava2 | Reactive Programming library

 by   Polidea Java Version: 1.7.1 License: Apache-2.0

kandi X-RAY | RxAndroidBle Summary

kandi X-RAY | RxAndroidBle Summary

RxAndroidBle is a Java library typically used in Programming Style, Reactive Programming applications. RxAndroidBle has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.

RxAndroidBle is a powerful painkiller for Android's Bluetooth Low Energy headaches. It is backed by RxJava, implementing complicated APIs as handy reactive observables. The library does for you:. For support head to StackOverflow #rxandroidble. Read the official announcement at Polidea Blog.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              RxAndroidBle has a medium active ecosystem.
              It has 2921 star(s) with 497 fork(s). There are 104 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 41 open issues and 486 have been closed. On average issues are closed in 29 days. There are 5 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of RxAndroidBle is 1.7.1

            kandi-Quality Quality

              RxAndroidBle has 0 bugs and 0 code smells.

            kandi-Security Security

              RxAndroidBle has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              RxAndroidBle code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              RxAndroidBle is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              RxAndroidBle releases are available to install and integrate.
              Deployable package is available in Maven.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              RxAndroidBle saves you 7118 person hours of effort in developing the same functionality from scratch.
              It has 15747 lines of code, 1348 functions and 263 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed RxAndroidBle and discovered the below as its top functions. This is intended to give you an instant insight into RxAndroidBle implemented functionality, and help decide if they suit your requirements.
            • Construct a byte array from a scan record
            • Adds a field to the advertisement packet
            • Checks if the specified UUID is a 32 bit UUID
            • Format UUID to byte array
            • Helper method to actually write the queue
            • Creates and returns a function which returns a function which returns a function which can be invoked when the Observable fails
            • Creates a function which returns a function that when the buffer is not empty
            • Creates an scan callback that can be used for scan results
            • Converts a scan error code to a BleScanException
            • Performs the actual disconnect operation
            • Sets the custom logger implementation
            • Initializes the BluetoothGatt characteristic
            • Gets the string value of the specified byte array
            • Add a scan result
            • Initializes the BeaconView
            • Set up the device to be created
            • Get the current location provider status
            • Runs the given operation on the queue
            • Returns a scan setup for the given scan settings
            • Performs a scan
            • Returns the integer value from the given byte array
            • Writes this field to Parcelable
            • Asynchronously scans a pending intent
            • Create a new long - write operation builder
            • Initializes the device
            • Handle notification event
            Get all kandi verified functions for this library.

            RxAndroidBle Key Features

            No Key Features are available at this moment for RxAndroidBle.

            RxAndroidBle Examples and Code Snippets

            Mock different answers and exceptions after several calls with Mocktail
            Lines of Code : 18dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import 'package:http/http.dart' as http;
            import 'package:mocktail/mocktail.dart';
            
            class MockClient extends Mock implements http.Client {}
            
            final mockClient = MockClient();
            
            final List Function(Invocation)> answers = [
             (_) => throw 
            Getting null when using MockClient
            Lines of Code : 27dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            test('Adding data manually', () async {
              final MockClient ghibliMock = MockClient();
            
              when(ghibliMock.films).thenReturn(FilmModel(
                director: 'test director',
                description: 'test',
                releaseDate: 'test',
                producer: 'test'
              )
            How to test nulls using mockito?
            Lines of Code : 16dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            class MockClient extends Mock implements GhibliFilms {
              @override
              Future> getFilms() async {
                return Future.value(null); // this is not that important
              }
            }
            
            void main() {
              final GhibliFilms ghibliMock = MockClient();
            
              // async
            Flutter Test Mock GraphQL Mutation result
            Lines of Code : 101dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            class MockClient extends Mock implements Client {
              MockClient({
                this.mockedResult,
                this.mockedStatus = 200,
              });
              final Map mockedResult;
              final int mockedStatus;
            
              @override
              Future send(BaseRequest request) {
                return Fut
            Jest Unit Test for chained function calls
            Lines of Code : 42dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            jest.fn(function () {
              return this;
            });
            
            // module scope
            jest.mock('../../config', () => ({
              __esModule: true,
              default: mockClient
            });
            
            const mockClient = {
              items: jest.fn(),
              type: jest.fn(),
              ...
            };
            ...
            Java write test for inputStream with javax.ws.rs.client
            Lines of Code : 24dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                Client mockClient = Mockito.mock(Client.class); 
                @Before
                public void initMocks() {
                    MockitoAnnotations.initMocks(this);
                    PowerMockito.mockStatic(ClientBuilder.class);
                    PowerMockito.when(ClientBuilder.newCli
            How to create a call adapter for suspending functions in Retrofit?
            Javadot img7Lines of Code : 146dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            // build.gradle
            
            ...
            dependencies {
                implementation 'com.squareup.retrofit2:retrofit:2.6.1'
                implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
                implementation 'com.google.code.gson:gson:2.8.5'
            }
            
            How best to stub/mock rest API calls in Flutter Integration tests
            Lines of Code : 26dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import 'package:http/testing.dart';
            import 'package:http/http.dart';
            
            MockClient integrationTestMockClient = MockClient((request) async {
              switch (request.url.toString()) {
                case 'https://staging.company.com/api/customer/123':
                  re
            How do I mock and test chained function with jest?
            Lines of Code : 82dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            const client = {
              items: () => {
                return client;
              },
              type: (name: string) => {
                return client;
              },
              toObservable: () => {
                return client;
              },
              subscribe: handler => {
                handler();
                return client;
              }
            };
            
            e
            How to mock http request in flutter integration test?
            Lines of Code : 18dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import 'package:flutter/widgets.dart';
            import 'package:flutter_driver/driver_extension.dart';
            import 'package:shared_preferences/shared_preferences.dart';
            import 'package:utgard/business/config/globals.dart';
            import 'package:utgard/main.da

            Community Discussions

            QUESTION

            Sending data over the air and after completion end the operation using RxAndroidBLE
            Asked 2022-Jan-02 at 10:07

            I am trying to send the 128 bytes of the block to BLE Controller using the RxAndroidBle library. the flow to send data from mobile to BLE controller is as follows

            1. Connect with BLE Controller
            2. Start OTA (sending 1)
            3. Send CRC (of the data block)
            4. Send data block
            5. wait for 2 seconds
            6. repeat step 3
            7. END OTA (sending 2)

            Here is snapshot of a code

            ...

            ANSWER

            Answered 2022-Jan-02 at 10:07

            You can use flatMapIterable() with toList(). Try to add toList() operator before OTA_DATA_END command like:

            Source https://stackoverflow.com/questions/70548331

            QUESTION

            RxAndroidBLE already connected and can't send data to IoT device
            Asked 2021-May-13 at 19:25

            I have an IoT device with BLE on it and also I have a smartphone which support BLE protocol. I am using RxAndroidBle: com.polidea.rxandroidble2:rxandroidble:1.11.1 The problem is to communicate each other. I have established connection:

            ...

            ANSWER

            Answered 2021-May-13 at 19:25

            Is there a way to send data every 300 ms to IoT device?

            Of course there is. If there is no external source of the data to send one could use code similar to:

            Source https://stackoverflow.com/questions/67458703

            QUESTION

            Is it require to have location permission and Location service enabled to connect to BLE device via MAC ID
            Asked 2021-Apr-16 at 19:52

            i have been using rxAndroidBLE lib on my android app to scan and connect to BLE devices. i know that location permission and location services needs to be enabled to scan nearby BLE devices but if i just want to connect to nearby BLE devices with it's macID(that i already know) is it still require to ask user to provide location permission and enable location services?

            i have tried to connect to BLE device with it's MACID without granting Location permission or enabling Location services still i'm able to connect to BLE device on my device(Samsung S20) but some of our users are not able to connect to their BLE device.

            ...

            ANSWER

            Answered 2021-Apr-16 at 19:52

            No it's not required, but please see https://stackoverflow.com/a/57099437/556495 why you can't always connect using only the Bluetooth Device Address.

            Source https://stackoverflow.com/questions/67130036

            QUESTION

            restart reading data in onErrorResumeNext when BleAlreadyConnectedException is encountered
            Asked 2021-Feb-16 at 09:27

            I am using RXAndroidBle library to connect and read data from the BLE device. I have set the establishConnection function to true i.e. auto-connect to true. when the BleAlreadyConnectedException is occurring I want to capture that exception and restart the flow of reading data because every time disposing and connecting to BLE device is creating issues. so better to keep the connection alive and re-read the data.

            In onErrorResumeNext i to re-call the functions writeStatus, readModelInfo,getReadings and so on. Now sure how would I achieve it.

            ...

            ANSWER

            Answered 2021-Feb-16 at 09:27

            Put the onErrorResumeNext closer to the connection code.

            Source https://stackoverflow.com/questions/66173273

            QUESTION

            How to enable/disable to notification/indication in RxAndroidBLE
            Asked 2021-Jan-20 at 17:41

            I am creating a RxJava2 chain where in I want to enable and disable notification. the flow I am setting is as follows.

            1. establish a connection.
            2. set the notification to READ_STATUS UUID.
            3. if the returned byte is zero then perform a write byte 01 to WRITE_STATUS UUID and after WRITE_STATUS, enable the notification of READ_STATUS UUID to verify it has byte value 1.
            4. else if the returned byte is 1 then just enable other indicators (UUID1, UUID2,UUD3) and read the value.

            I have a problem at step 2 and 3 where I am reading the value of READ_STATUS UUID by enabling the notification. in order to re-read the value, I probably need to disable the notification and then again enable it. And to disable to the notification I have to dispose that particular setupNotification .

            Code is as follows

            ...

            ANSWER

            Answered 2021-Jan-20 at 16:36

            To unsubscribe or to dispose setupNotification or setupIndication one can use the following code. I am sure there could be different ways but so far I could find this

            Source https://stackoverflow.com/questions/65778811

            QUESTION

            RxJava take(1) completes wheras Observable.just() does not
            Asked 2020-Dec-07 at 14:26

            I use RXAndroidBle to connect to Bluetooth devices. I use establishConnection to get the connection observable and want to convert this Observable to an Completable. This code works and the completable completes as expected:

            ...

            ANSWER

            Answered 2020-Dec-07 at 14:26
            Problem Never completes:

            Source https://stackoverflow.com/questions/65182582

            QUESTION

            Can't restart scan after disposing of the first connection
            Asked 2020-Sep-28 at 17:45

            I have a rather long chain of Rx operations for my initial scan, connection and authorization. Here's the code.

            ...

            ANSWER

            Answered 2020-Sep-28 at 17:45

            The reason why you cannot start a new scan lays in how you dispose the previous one. If you would look into the implementation or CompositeDisposable.add() Javadoc you would see that:

            Source https://stackoverflow.com/questions/64069616

            QUESTION

            Disconnecting and closing BLE connection stops classic Blutetooth PBAP profile
            Asked 2020-Sep-25 at 09:45

            I have a setup with two Android devices: an android phone and a custom hardware running Android 10. The latter acts as a BLE Server, which is discoverable always with the same static MAC address. Also when that custom HW is paired with the phone it has access to phone's contacts and calls history. That HW can also play media (sound) streamed from the phone.

            I use RxAndroidBle 1.11.0 library for BLE communication. As soon as I exchange some data via BLE Characteristic I unsubscribe from the RX observable so the library effectively calls: bluetoothGatt.disconnect() then blutetoohGatt.close() (all those inside the DisconnectOperation class).

            My problem is the fact that based on my observations, calling blutetoohGatt.disconnect() disconnects the classic BT profile (PBAP) as well.

            Is it an expected behaviour?

            I have investigated the code of generic Android P framework and it looks that calling bluetoothGatt.disconnect() -> bluetoothGatt.close() completely disconnects the device described by the given MAC Address: BluteoothGatt#disconnect() BlutetoothGatt#close() BlutetoothGatt#unregisterApp()

            I would risk a statement that I have quite unusual BLE use-case scenario where the phone (Central/Client) and the peripheral (custom Android HW/Server) are connected simultaneously via Classic BT profile and via BLE. I suspect that disconnecting/closing device using its BT MAC address disconnect both profiles, hence the contacts sharing stops working. Is it possible to disconnect BLE connection only, but not affect the classic BT (SPP/PBAP) connections between the two devices?

            ...

            ANSWER

            Answered 2020-Sep-25 at 09:45

            After further investigation described on that Github issue I realised that my custom hardware is equipped with dual-mode BT adapter so it supports classic BT (BR/EDR) and the BLE one. As soon as I pair an Android phone with the custom hardware via System Settings, classic BT profiles are bonded, but also my GATT Server advertises relevant services using the same MAC address which is used by the BR/EDR. Disconnecting BLE client connection disconnect BD/EDR as well.

            What helps in my case is to not start pairing via System Settings, but let the GATT server advertise and let my BLE client app to connect (and trigger pairing) first. As a result I have a BLE connection with server available under "AA:AA:AA:AA:xx", while the classic BT profiles are connected to "BB:BB:BB:BB:yy" interface on the custom hardware. Now, disconnecting BLE profile does not disconnect the classic one.

            I am looking for a solution which would allow my GATT Server to be advertised with BLE only, but no luck so far. Here are some interesting links I have found:

            connectGatt creates connection over BT Classic instead of BLE

            how to force BLE "just works" pairing in Android

            BLE Dual-Mode

            Source https://stackoverflow.com/questions/63791301

            QUESTION

            In RxAndroidBLE, RxBleDevice.establishConnection() method is blocking infinitely when autoConnect=true
            Asked 2020-Jul-30 at 21:15

            I am using RxAndroidBle library for communication with BLE device. The goal is to perform BLE scan, find device and establish connection to it. I am using autoConnect = true to keep connection running in background, however, I noticed that, sometimes, this method is getting blocked (I have 60 seconds timeout) and it times out. Also, when nRF Connect is running in background, it seems the connection succeed. Here is the log when issue occurs:

            ...

            ANSWER

            Answered 2020-Jul-30 at 21:15

            When using autoConnect = true Android uses relaxed initial scan parameters. Depending on how robust your mobile Bluetooth chipset is and what are the advertising parameters of your peripheral the connecting process may take even many minutes.

            So, is there a way to improve the connection parameters from the app side, to make connection more aggressive or something similar?

            Yes, use autoConnect = false. This makes initial (implicit) scanning more aggressive but limits its time to 30 seconds. This is how Android did implement it.

            Does nRF Connect do something different than what library does, so it makes app connecting faster to device?

            If you have nRF Connect opened in the background — be aware that it "steals" BLE connections. I.e.:

            1. Your peripheral is disconnected
            2. Open nRF Connect
            3. Put nRF Connect to background
            4. Open your app
            5. Connect your peripheral
            6. Close your app
            7. Observe that your peripheral is connected to the phone until nRF Connect is not killed or you do not manually disconnect your peripheral from it

            Source https://stackoverflow.com/questions/63123628

            QUESTION

            Adding a delay in between each batch write using long write builder
            Asked 2020-Apr-15 at 10:27

            I'm trying to add a delay in between each batch write and I managed to get it working by modifying this example but I'm not sure this is the correct way to achieve this?

            ...

            ANSWER

            Answered 2020-Apr-15 at 10:27

            Your approach would delay next (sub)writes if Observable.timer().repeat() would emit after the booleanObservable. Unfortunately that would work only for the second (sub)write as after that .repeat() would start to emit very quickly as it does not resubscribe to the upstream Observable. From .repeat() Javadoc:

            Returns an Observable that repeats the sequence of items emitted by the source ObservableSource indefinitely.

            If you would use Observable.timer(delayInMillis, MILLISECONDS).repeatWhen(completions -> completions) or Observable.interval(delayInMillis, MILLISECONDS) then these would make writes happen not more frequent than delayInMillis, MILLISECONDS apart.

            If you would like to give the peripheral delayInMillis, MILLISECONDS time before issuing next write then there seems to be a simpler approach:

            Source https://stackoverflow.com/questions/61223129

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install RxAndroidBle

            The first step is to include RxAndroidBle into your project.

            Support

            If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request. When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code compiles by running ./gradlew clean checkstyle test.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
            Maven
            Gradle
            CLONE
          • HTTPS

            https://github.com/Polidea/RxAndroidBle.git

          • CLI

            gh repo clone Polidea/RxAndroidBle

          • sshUrl

            git@github.com:Polidea/RxAndroidBle.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Reactive Programming Libraries

            axios

            by axios

            RxJava

            by ReactiveX

            async

            by caolan

            rxjs

            by ReactiveX

            fetch

            by github

            Try Top Libraries by Polidea

            react-native-ble-plx

            by PolideaJavaScript

            RxBluetoothKit

            by PolideaSwift

            SiriusObfuscator

            by PolideaC++

            Cockpit

            by PolideaKotlin