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
2
votes
0 answers

device not connecting mobile device to device through bluetooth low energy

How to communicate mobile device with BLE when an application installs in mobile and trying to get other mobile device battery information where ScanCallback does not return any information on searching BLE device. private ScanCallback…
Salman
  • 159
  • 1
  • 2
  • 7
2
votes
2 answers

How to connect with BLE device for first time (Android)

I was going through BluetoothGatt.java and found the method boolean connect(Boolean autoConnect, BluetoothGattCallback callback, Handler handler) The documentation just above this method specifies that this is used to initiate a…
Saurabh
  • 434
  • 1
  • 4
  • 19
2
votes
0 answers

Android BLE: Set a float to a BluetoothGattCharacteristic

I have to set a float value to BluetoothGattCharacteristic, for example Temperature Measurement with the BluetoothGattCharacteristic.FORMAT_FLOAT and an offset. I'm not sure if it should be 0 or 1. The problem is that there is a method for…
TheSlawyan
  • 21
  • 2
2
votes
2 answers

BLE Advertise 32-bit Service-UUID in Android Oreo

I have a small app which just performs a BLE Advertising. The app runs on a Nexus 5x with Android 8.0 This is the code to start BLE advertising: private fun startAdvertising() { val serviceUuid =…
Christopher
  • 9,682
  • 7
  • 47
  • 76
2
votes
1 answer

Getting Response for Android BLE Write Characteristic

I am invoking the writeCharacteristic both using the WRITE_TYPE_NO_RESPONSE and without it.Am I supposed to get the response out of both or one or none? Is there any callback to catch this response? Does onReliableWriteCompleted callBack ensures the…
Raulp
  • 7,758
  • 20
  • 93
  • 155
2
votes
1 answer

BluetoothServiceJni: An exception was thrown by callback 'btgattc_notify_cb'

I am using Android ble to develop an application. The app will connect with the external device using ble. The external device has a sensor that records data and as soon as the android device comes in range, data transmission begins. The android…
Saurabh
  • 434
  • 1
  • 4
  • 19
2
votes
1 answer

RxAndroidBle WRITE_TYPE_DEFAULT or WRITE_TYPE_NO_RESPONSE

I was wondering which strategy the RxAndroidBle library uses regarding write acknowledgements: WRITE_TYPE_DEFAULT or WRITE_TYPE_NO_RESPONSE? Furthermore, should I wish to set (or query) this setting, how might one do this in RxAndroidBle? I'm in the…
Steve Yohanan
  • 757
  • 5
  • 17
2
votes
0 answers

Android BluetoothGatt.getServices(xyz) in onServicesDiscovered returns null for Service xyz listed in onScanResult ScanRecord.getServiceUuids()

I've been doing BLE on Android since 2013/API18/4.3. I know what I am doing, but I can't figure out this simple problem. I am successfully scanning BLE devices and in ScanCallback.onScanResult(...) I log ScanRecord.getServiceUuids() (seen here w/ a…
2
votes
2 answers

Logging scanResult in Polidea - RxAndroidBle Scanning

I am trying to use the RxAndroidBle lib (https://github.com/Polidea/RxAndroidBle). I want the app the start and scan for BLE devices. I want to print the found devices in the LogCat. How can I do this? RxBleClient rxBleClient; RxBleScanResult…
2
votes
1 answer

Android BLE startLeScan scan for already connected device

I'm currently connecting my android device with another bluetooth device using BLE. The issue is, how do I scan for already connected devices? In my first approach, I did not call stopLeScan before the connection method. This had no problem with…
March3April4
  • 2,131
  • 1
  • 18
  • 37
2
votes
1 answer

Android BLE connection speed issue

My android application uses the BluetoothAdapter.startLeScan() to scan for result before manually asking for it to stop by pressing a button. Will this type of attitude affect the time of ble connection time? I think the scanning is blocked when…
March3April4
  • 2,131
  • 1
  • 18
  • 37
2
votes
2 answers

Maximum no of device that can connect to BLE(BluetoothGattServer) server android

Does anybody knows the maximum number of device that can be connected to ble peripheral ? I tried with two devices and it connects well but the third device is not able to connect to Android BLE peripheral/ BluetoothGattServer. Is there any…
DAMM108
  • 970
  • 2
  • 13
  • 27
2
votes
1 answer

Android BLE read data rate is slow when device is paired

I am developing an Android BLE app which sends multiple read requests per second (~ 10 samples/second). I have noticed that when the ble device is paired (bonded) to the phone, the reading rate is slow (~ 1 sample/sec), while the read rate is good…
Amani Elsaed
  • 1,558
  • 2
  • 21
  • 36
2
votes
3 answers

BluetoothLescan() not finding any devices

I've been having some problems getting Bluetooth to scan for devices with my Samsung Galaxy s5. I'm on Android 6.0 and have set up permissions for my app to scan like so: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) // Android M…
joey
  • 241
  • 1
  • 4
  • 16
2
votes
0 answers

BLE scan in sleep mode

I'm developing a android app using ble. I want schedule a scan every 10 second. It work but when my device is in background, it doesn't work. in Oncreate() i call StartHandler(); public class MyService extends Service{ ...... .... public void…