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
48
votes
1 answer

Game Command format between bluetooth controller and console

I am creating an Android project, in which I have to make android wearable smart watch as game controller which can send commands to games running on handheld device connected to that smartwatch over BLE(Bluetooth Low Energy). I designed controller…
Manish Dubey
  • 4,206
  • 8
  • 36
  • 65
14
votes
1 answer

Android Companion device pairing: how to use REQUEST_COMPANION_RUN_IN_BACKGROUND permission?

I'm currently testing Android companion device pairing and I'm not sure how to benefit from the REQUEST_COMPANION_RUN_IN_BACKGROUND permission. In one part of Google documentation is says: After the device is paired, the device can leverage…
13
votes
3 answers

BluetoothGattServer cancelConnection does not cancel the connection

I have Android application which exposes BLE Server. I connect with BluetoothGattServer#connect. It works - my app gets call to BluetoothGattServerCallback#onConnectionStateChange with STATE_CONNECTED. When I'm done with the client I try to…
12
votes
4 answers

Android BLE Gatt connection change statuses

I have an android app to connect to a BLE device and write to it. I can successfully connect, read and write to it. As a part of testing, we are trying different disconnection scenarios. Sometimes, if BLE device disconnects the connection, I get the…
12
votes
2 answers

Android stops finding BLE devices: onClientRegistered() - status=133 clientIf=0

I am developing an app in which I can both find and configure BLE devices. I am using standard Android BLE API, but recently I've encountered some strange problems. When I turn on my app the BLE scan works OK. I am scanning…
fragon
  • 3,391
  • 10
  • 39
  • 76
11
votes
2 answers

What is the max concurrent Ble connections android M+ can have

My app required to connect 9 Ble devices concurrently. In this article and any other resource it write that android 4.4+ can connect only to 7 devices. Is there anything new in M or N versions? Thanks.
Maor Hadad
  • 1,850
  • 21
  • 36
8
votes
1 answer

Restrictions when scanning in background on Android 10?

There seems to be a lot of "hidden features" regarding Bluetooth scanning on Android. For starters there is a "30s limit" (Android 7.0 ble scan no result). Then you have to set a ScanFilter in background mode otherwise you get no results (can't find…
Alix
  • 2,630
  • 30
  • 72
8
votes
2 answers

Scanning for BLE peripherals with a scan filter based on advertised service UUID

I have a custom BLE peripheral that advertises data like this: In other words, my BLE peripheral advertises a service UUID associated with a unique identifier in advertised service data, but it does not add that service UUID to advertised service…
Sebastien
  • 3,583
  • 4
  • 43
  • 82
8
votes
0 answers

Android BLE device scan with device name filter is not working

I am using device name filter to connect to a specific BLE device. But my scan call back is not executing. It works fine when I use MAC address as filter. Is this a known issue or bug? I am testing on Asus Tablet with Android 6.0. As I am reading…
7
votes
4 answers

Disconnecting a BluetoothDevice without BluetoothGATT

My app talks to a BLE peripheral. Sometimes the app is started with that peripheral already connected. I can retrieve the device by calling: BluetoothManager manager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE); List
James Whong
  • 231
  • 5
  • 5
7
votes
2 answers

Reacting to BLE directed advertising (ADV_DIRECT_IND) in Android

How to react to directed advertising (ADV_DIRECT_IND == 0001) in Android? There is a BLE-gadget which sends directed advertising to an Android phone (using hardcoded MAC address of the phone for now) and in my Android app I would like to react and…
6
votes
6 answers

Android BLE onScanResult is never called in the background on Android 11. Was working on Android 10

I have an app which scans for BLE devices. It was working perfectly on Android 10, but since I updated my phone to Android 11, the onScanResult just never gets called if I put the application to the background, or if I lock the screen. This is quite…
Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222
6
votes
2 answers

Nearby Messages using an IntentService

Initially I setup a BroadcastReceiver to receive intents from the Nearby Messages API. class BeaconMessageReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { …
Bryan
  • 14,756
  • 10
  • 70
  • 125
6
votes
3 answers

I want to identify the BLE wheel and crank sensor data from the 11-bytes data from a mobile application we have developed

I want to identify the wheel and crank sensor data from the 11-bytes data. I have tried to parse the 11-bytes hex data which i got in our mobile application as per the split ups in the link…
6
votes
1 answer

Android BLE readCharacteristic fails

I'm trying to read the initial state of a BLE device when I connect to it. Here's the code I have to try to do that: @Override public void onServicesDiscovered(BluetoothGatt gatt, int status) { if(status == BluetoothGatt.GATT_SUCCESS) { …
CaseyB
  • 24,780
  • 14
  • 77
  • 112
1
2 3
18 19