android-ble | DeviceHive Bluetooth Low Energy bridge for Android | Networking library

 by   devicehive Java Version: v3.0 License: Non-SPDX

kandi X-RAY | android-ble Summary

kandi X-RAY | android-ble Summary

android-ble is a Java library typically used in Networking applications.,roid-ble has no bugs, it has no vulnerabilities, it has build file available and it has high support. However android-ble has a Non-SPDX License. You can download it from GitHub.

DeviceHive Bluetooth Low Energy bridge for Android
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              android-ble has a highly active ecosystem.
              It has 38 star(s) with 12 fork(s). There are 35 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              android-ble has no issues reported. There are 1 open pull requests and 0 closed requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of android-ble is v3.0

            kandi-Quality Quality

              android-ble has 0 bugs and 0 code smells.

            kandi-Security Security

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

            kandi-License License

              android-ble has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              android-ble releases are available to install and integrate.
              Build file is available. You can build the component from source.
              android-ble saves you 1174 person hours of effort in developing the same functionality from scratch.
              It has 2649 lines of code, 228 functions and 40 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed android-ble and discovered the below as its top functions. This is intended to give you an instant insight into android-ble implemented functionality, and help decide if they suit your requirements.
            • Performs a device command
            • Calls the given operation on a device
            • Start scanning for Bluetooth
            • Parse a hex binary string into a byte array
            • Initializes the bridge
            • Start scan
            • Get the broadcast receiver
            • Returns a new instance of the BTLedViceHive
            • Initializes the instance
            • Start service
            • Initialize preferences
            • Invoked when a job is done
            • Callback when a device is found
            • Converts byte array to string
            • Called when a characteristic read is received
            • Compares two Bluetooth devices
            • Install the application
            • Called when the data has been changed
            • Start Bluetooth device
            • Creates and returns a ScanCallback which returns a callback that corresponds to the given ScanCallback
            • Callback method for receiving Bluetooth state
            • Disconnects from the device
            • Called when a BluetoothGatt is discovered
            • Validates the values in the buttons
            • Called when a connection is connected
            • Create the location request
            Get all kandi verified functions for this library.

            android-ble Key Features

            No Key Features are available at this moment for android-ble.

            android-ble Examples and Code Snippets

            No Code Snippets are available at this moment for android-ble.

            Community Discussions

            QUESTION

            How to implement a custom UUID for bluetooth broadcast
            Asked 2021-May-06 at 14:56

            I want to change my android device's Bluetooth UUID to a predefined value so that my BLE beacon can recognize it without pairing with it.

            From this question I gathered that I'll have to change the service UUID but I can't find the relevant documents or tutorials.

            How can I achieve this change of UUID via my app?

            ...

            ANSWER

            Answered 2021-May-06 at 14:56

            Have you looked at the Android API documentation?

            You use this https://developer.android.com/reference/android/bluetooth/le/AdvertiseData.Builder#addServiceUuid(android.os.ParcelUuid) function to set a custom service uuid to be advertised.

            A general tutorial for advertising can be found here: https://source.android.com/devices/bluetooth/ble_advertising.

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

            QUESTION

            Questions on creating a service that connects automatically to a BLE device on android
            Asked 2020-Dec-11 at 00:10

            I am implementing a service that uses the autoconnect feature of bluetoothGatt to connect to the device and monitor it while it is being connected.

            I work on the assumption that the device is already bonded (a coworker is responsible for that part) so autoconnect should not have any problems

            my code is as follows:

            ...

            ANSWER

            Answered 2020-Dec-10 at 21:44

            First of all, if you are intending to distribute your app to Google Play Store, you need to be targeting minimum api level 29 if I'm not mistaken, hence you should be using either JobService along with JobScheduler or WorkManager, instead of Service. This is to support the background limitations from Oreo(26) onwards.

            a) if you properly implement any of the two options I mentioned above, you can write a proper service that will not terminate unless you stop it. Here are some resources on JobService : (resource1, resource2, resource3)

            b) You can re-register as you please upon the onStartJob() method of your JobService, which will recreate your app.

            c) Each time you are done with the peripheral ble device, you need to close the gatt connection with it. Here is a snippet from the BluetoothGatt class

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

            QUESTION

            Android BLE, scan started, finds devices but does not connect with filter (ESP32 & Samsung)
            Asked 2020-Oct-28 at 21:30

            I have been working through several BLE tutorials to develop an app to connect to an ESP32, but I cannot get the code to connect to the ESP32. I am using a Samsung phone which requires a time delay, but I have tried other phones and still cannot connect the ESP32 to the mobile app.

            If I run a BLE scanner app I can connect to the ESP32, so I believe the ESP32 side is okay. If we scan for devices we can see it in the bluetooth device list.

            The code is setup to detect and connect, I have tried a UUID and device name filer, but it will not connect. The ScanCallback is been triggered and we get the function onBatchScanResults been called, so we can see a list of devices but it will not connect to the ESP32. I think it should connect automatically with the gatt functions.

            I cannot workout why it will not auto connect to the ESP32, as it's seen the devices and the scan connect is been trigged. Any help would be highly appreciated to fix this issue, as I have ran out of idea to fix it.

            ...

            ANSWER

            Answered 2020-Oct-28 at 20:28

            From the logs I see "found something 2" is logged in onBatchScanResults() method of ScanCallback. You should handle this event. Call the same connectGatt which is used in onScanResult() method.

            When device connection successful in order to read messages from device you should subscribe to services and setCharacteristicNotification for PROPERTY_NOTIFY type characteristics.

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

            QUESTION

            Android BLE client only returns 600 byte of data in onCharacteristicRead
            Asked 2018-Oct-25 at 23:28

            I've got a Bluetooth server that uses bleno and returns a list of available Wifi networks to the client. The code for readCharacteristic looks basically like this:

            ...

            ANSWER

            Answered 2018-Oct-25 at 23:28

            For anyone who comes across this post also wondering why Android seems to return only 600 bytes for long GATT characteristics like this question is asking about, it all comes down to how Bluedroid (Android's Bluetooth stack) implements their GATT Client and how its out of spec. In my case, I was using an ESP32-based IoT device as my GATT Server and Android (SDK 24) for the GATT Client.

            According the spec (Bluetooth Core 4.2; Vol 3, Part F: 3.2.9), the maximum size for a characteristic value (inherited from ATT's attribute value) is 512 bytes. However, for some reason, Bluedroid does not attempt to enforce this requirement, instead decided upon a maximum size of 600; which can be seen if you dive into the Bluedroid source and find the macro GATT_MAX_ATTR_LEN which is set to 600 (stack/include/gatt_api.h:125). Since in my case (and yours it seems) I was implementing the read request response code, I did not see to enforce the 512 byte limit on reads for characteristics either.

            Now, its important to realize just how it seems Bluedroid reads characteristics and how that relates to both the MTU size, the maximum size of a read (should be 512, but is 600 for Bluedroid) and how to handle data longer than that maximum size. The MTU size is the largest packet size on the ATT level you can use. So, for each call to BluetoothGatt.readCharacteristic, you may be sending one or more read requests to the server depending on if Bluedroid thinks the characteristic size exceeds the MTU size. On a low level, Bluedroid will first send a ATT Read Request (0x0a) and if the packet is MTU bytes in length, it will follow up with a ATT Read Blob Request (0x0c) with the offset set to the MTU size. It will continue to send ATT Read Blob Requests until either the ATT Read Blob Response is less than MTU bytes in length or until the maximum characteristic size is reached (ie, 600 for Bluedroid). Its important to note that if the MTU size is not a perfect multiple of 600 for data longer than 600 bytes, the remaining bytes will be discarded (as Bluedroid never actually expects to read 600 bytes since it thinks the GATT Server will enforce the 512 byte limit on characteristic sizes). So, if your data exceeds the 600 byte limit (or 512 limit for safety), you should expect to call BluetoothGatt.readCharacteristic multiple times. Heres a simple example for reading lots of data on the Android side (sorry Im not using bleno so cannot give you the code to fix that side), it relies on first sending the length of the data as a unsigned 32-bit integer and then reading out the data with repeated calls to BluetoothGatt.readCharacteristic if the data is longer than 600 bytes:

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

            QUESTION

            Android BLE unexpectedly and repeatedly reconnects to peripheral
            Asked 2018-May-15 at 08:44

            I am developing an Android app that interfaces with a BLE device and recently stumbled across some strange behavior: when the app disconnects from the device, a few seconds later something else seems to establish the connection.

            I am in the process of characterizing the issue more fully and have been focused on the Bluetooth MAP and PBAP profiles; they show up in the logs around the point of issue. I am unsure, however, if this is the root cause, nor have I found a workaround.

            The app supports API 23-25. To date, I have only experienced the issue in phones with SIM cards present, which points again to PBAP since many phones seem to support this profile only with a SIM card. I haven't yet been able to reproduce on API 23, but for now those test phones do not have SIM cards.

            The BLE device has nothing to do with automotive application, nor does it have the ability to deal with Contacts or Messaging. I haven't intentionally enabled any of this within the app. Furthermore, there is no pairing / bonding between my app and the device, nor does the device support pairing / bonding.

            In most cases, the attempt to reconnect happens once, a few seconds after device disconnect via the app. Subsequent connect-disconnect sequences in the app have the same behavior. However, I have seen in at least one instance where the reconnects (outside of the app) continue indefinitely every few seconds.

            The only thing that seems to resolve the issue short-term is to cycle Bluetooth on the phone, or force-stop the Bluetooth Share process. I don't believe the reconnects come back on their own, but it is common that they do reappear once the user connects-disconnects with the device through my app.

            I am not very familiar with PBAP / MAP so am unaware how they get enabled or, if possible, how to disable them. I am not sure if they are the culprit, but they appear in the logs at the moment of reconnect.

            Following is the log statements around the point of disconnection and subsequent reconnection. The interface name here is "Foo04" with MAC = B0:B4:48:E8:FA:04.

            ...

            ANSWER

            Answered 2017-Apr-28 at 20:58

            After a great deal of investigation, I was able to determine the root cause of my issue: Spotify.

            Having Spotify installed on the Android device was enough to manifest this aberrant behavior; the user need not have logged into or ever started the Spotify app. Uninstalling or force-stopping the app in all cases rectified the issue.

            It appears that Spotify has a service that registers for disconnects from any bluetooth peripheral. When the system notifies Spotify, the service immediately connects to the just-disconnected peripheral --- I didn't bother to characterize the communication from Spotify. After ~5 seconds the connection is dropped; however, since Spotify is notified of bluetooth disconnection events, the service again tries to connect with the peripheral. This effectively is an infinite loop that can be aborted only by force-stopping Spotify or cycling bluetooth on the Android device.

            To investigate, I developed a simple app that is notified of and reports bluetooth connection and disconnection (ACL_CONNECTED, ACL_DISCONNECTED) events. I used a BLE scanner on my Android device and connected / disconnected with a variety of bluetooth peripherals. My test app would show my initial interaction with the peripheral followed by an infinite stream of connect then disconnect events. Again, this would continue until Spotify was force-stopped.

            Following is example logging...

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

            QUESTION

            Android BLE handling disconnect timeout
            Asked 2018-Mar-22 at 08:54

            Referencing blog posts like this one, and SO questions like this one. I am going to assume that this is a general behavior (and not a bug on my side). The common answer seems to be something to the effect of: "Change the BLE firmware so it actively disconnects."

            The question which is not well addressed is how Android apps handle what must be a very common occurrence? Connection is lost unexpectedly due to "range", I.E. radio signal strength.

            Is there a way for an app to be notified "immediately" on the loss of connection?

            It does seem unrealistic that all apps just sit there for something like the 20 seconds which is mentioned as a core OS timeout value. Is that what we should all be doing even though my equivalent app on iOS knows about the loss of connections in less than 1s?

            Example 1

            One common type of BLE device is the "Find my keys" type. Many of them have a feature to alert the user when you leave the "keys" unintentionally. I assume that this uses the connection going down as an indicator of you walking too far away. Right?

            Example 2

            Your app is supposed to be notified of of value changes from a characteristic on the device. This would be any kind of sensor data where you have some threshold is being crossed for example. I can think of plenty of examples where you'd want to know immediately that your "sensor" is out or range.

            Known Workarounds

            I have seen one workaround amounting to constantly monitoring the RSSI to the BLE device but that seems like it would eat up a lot of battery. Similarly any failure to write to a characteristic (that normally succeeds) could also be used, again with battery life paying a price.

            Something approaching a definitive answer to this questions seems like a good resource.

            ...

            ANSWER

            Answered 2018-Mar-19 at 15:59

            In latest versions of Android they lowered the default timeout to 5 seconds, which is of course much better.

            I guess most peripherals send their own Connection Update request where they can set a different timeout value, which solves that issue (except for the small time between connection setup and until the connection update has gone through).

            So called "out of range" detector apps are according to me pretty useless and hard to make good because BLE devices will probably sometimes temporarily disconnect anyway, even though they are in range.

            For your actual question if it's possible to "immediately" get notified on the loss of the connection, the basic answer is no, because the Bluetooth controller doesn't send anything to the main cpu that packets were lost (that's the whole purpose of having a timeout so you are allowed to have packet losses). But you can of course try to poll the rssi or set up a flow where the peripheral every constant interval sends a notification and then you can in your app detect if you don't get the notification after some amount of time. But in this case it's smarter to just set your own timeout (from the peripheral) using the connection parameter update procedure.

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

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

            Vulnerabilities

            No vulnerabilities reported

            Install android-ble

            You can download it from GitHub.
            You can use android-ble like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the android-ble component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

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

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/devicehive/android-ble.git

          • CLI

            gh repo clone devicehive/android-ble

          • sshUrl

            git@github.com:devicehive/android-ble.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

            Explore Related Topics

            Consider Popular Networking Libraries

            Moya

            by Moya

            diaspora

            by diaspora

            kcptun

            by xtaci

            cilium

            by cilium

            kcp

            by skywind3000

            Try Top Libraries by devicehive

            devicehive-java-server

            by devicehiveJava

            devicehive-audio-analysis

            by devicehivePython

            esp8266-firmware

            by devicehiveC

            devicehive-video-analysis

            by devicehivePython

            IoT-framework

            by devicehiveGo