Questions tagged [android-ble]

In contrast to Classic Bluetooth, Bluetooth Low Energy (BLE) is designed to provide significantly lower power consumption. This allows Android apps to communicate with BLE devices that have low power requirements, such as proximity sensors, heart rate monitors, fitness devices, and so on.

Here is a summary of key BLE terms and concepts:

Generic Attribute Profile (GATT)—The GATT profile is a general specification for sending and receiving short pieces of data known as "attributes" over a BLE link. All current Low Energy application profiles are based on GATT.

The Bluetooth SIG defines many profiles for Low Energy devices. A profile is a specification for how a device works in a particular application. Note that a device can implement more than one profile. For example, a device could contain a heart rate monitor and a battery level detector.

Attribute Protocol (ATT)—GATT is built on top of the Attribute Protocol (ATT). This is also referred to as GATT/ATT. ATT is optimized to run on BLE devices. To this end, it uses as few bytes as possible. Each attribute is uniquely identified by a Universally Unique Identifier (UUID), which is a standardized 128-bit format for a string ID used to uniquely identify information. The attributes transported by ATT are formatted as characteristics and services.

Characteristic—A characteristic contains a single value and 0-n descriptors that describe the characteristic's value. A characteristic can be thought of as a type, analogous to a class.

Descriptor—Descriptors are defined attributes that describe a characteristic value. For example, a descriptor might specify a human-readable description, an acceptable range for a characteristic's value, or a unit of measure that is specific to a characteristic's value.

Service—A service is a collection of characteristics. For example, you could have a service called "Heart Rate Monitor" that includes characteristics such as "heart rate measurement." You can find a list of existing GATT-based profiles and services on bluetooth.org.

Link

Official documentation

video

sample code

281 questions
1
vote
1 answer

How to convert byte array data to float data type in android app

I am creating an app and have data coming in the function onCharacteristicChanged. The data I am getting is byte[]. I need to be able to take the data type and be able to have float numbers which are sent via Bluetooth to the app. Here is the…
1
vote
1 answer

Android Ble Server - Allow only previously connected device to connect

I have an android BLE client and an android BLE server. After the initial connection, I want the server to allow only the previously connected client device to connect. How to achieve this? What I have considered so far: 1. Bond the devices via…
heslegend
  • 86
  • 8
1
vote
1 answer

BLE scan callback not invoked on missing permission

I am using Samsung Note 8 (Android 9) and Samsung A50(Android 10). I am doing BLE scan which needs Bluetooth as well as location permissions (Android >=23). I am NOT providing the Location permission to the App before starting the BLE scan. While…
1
vote
1 answer

Android BLE: Is it possible to add Service Data and Manufacturer Data at the same time when advertising an iBeacon packet?

I'm currently doing an experiment in order to trigger a beacon detection device. Here is the sample of a detected beacon that can be used to trigger that device. In my experiment, I'm trying to replicate the beacon like in the above picture by…
1
vote
1 answer

Android BLE Scan - Cannot start unfiltered scan in screen-off

I am facing issue related to BLE advertisement scanning. After turning screen off my scanning is working for undefined time then stopping till I turn screen on. BtGatt.ScanManager is logging "Cannot start unfiltered scan in screen-off". Im providing…
1
vote
0 answers

Is there a way to get the BluetoothAdapter address if I do not plan to publish the app on Google play?

I am currently able to get the Bluetooth adapter mac address on devices with sdk from Marshmallow till Oreo. However, starting Pie, the retrieved mac address is null. The following method is working only till and including oreo.
Mena
  • 3,019
  • 1
  • 25
  • 54
1
vote
0 answers

Android : UUID of Custom Service of my BLE peripheral is not finding

One of My application is working as a Bluetooth peripheral, I add one Custom Service and 3 characteristics in it. My Client application after connected to peripheral discover its services, but UUID of my service is different in different clients.…
1
vote
0 answers

scanForPeripherals reports dozens of random peripherals (one physical device)

What Works: (prior to bonding scanForPeripherals reports 1x peripheral) What doesn't: (once bonded, scanForPeripherals reports 10-30x peripherals instantly) this happens instantly - the moment 'pair' dialog is confirmed -> bunch of peripherals are…
Pawel Klapuch
  • 380
  • 4
  • 15
1
vote
1 answer

Allow third party extensions/plugins for my Android app after installation - Bluetooth Low Energy

I have looked at several posts in stack overflow related to this topic and the closest I can get is sharing data between APKs using content providers. What I am looking to do is to first install my application which scans for and connects to…
Brian Reinhold
  • 2,313
  • 3
  • 27
  • 46
1
vote
0 answers

Android: Unable to scan for BLE devices even after using setEnableBle in LocationSettingsRequest

In my app I want to search nearby users using both GPS and BLE. I came across the SettingsClient which is used to enable GPS by showing a Popup in case it isn't enabled. Interestingly, it also has a setNeedBle method which as per the docs Sets…
varunkr
  • 5,364
  • 11
  • 50
  • 99
1
vote
3 answers

BLE Scan Freezes UI thread after 20 mins

I am trying to scan BLE devices continuously for a research project. I use LOW_LATENCY mode of BLE scanning. However, after 20 mins or so my UI freezes. Basically I press button it should start scanning for BLE devices, and when I press the button…
1
vote
1 answer

How do I format a byte array to be sent to a characteristic on a BLE device?

I connect to my device and attempt to write to its characteristic: scanSubscription = rxBleClient.scanBleDevices( ScanSettings.Builder() // .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) // change if needed //…
Martin Erlic
  • 5,467
  • 22
  • 81
  • 153
1
vote
1 answer

ConcurrentModificationException in ScanJob from android-beacon-library

I've an app scanning for BLE devices. In Crashlytics, I noticed the following crash: Fatal Exception: java.util.ConcurrentModificationException at java.util.ArrayList$Itr.next + 860(ArrayList.java:860) at…
matdev
  • 4,115
  • 6
  • 35
  • 56
1
vote
1 answer

Ble Android Advertising: AddServiceData

on my ble project i'm trying to add some service data to advertise data like this var data = AdvertiseData.Builder().apply { setIncludeDeviceName(true) addServiceData( ParcelUuid(BleConsts.SERVICE_UUID), …
giozh
  • 9,868
  • 30
  • 102
  • 183
1
vote
2 answers

bluetoothGatt.writeCharacteristic always return false with ble characteristic type is write_no_reponse

I am writing an Android app to talk with an BLE meter. I have been able to scan devices, connect to the target, discover services, get characteristics. However, when I try to write a write_no_reponse characteristics the method always returns false.…
syjsyj
  • 11
  • 4