Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BLE packet format in Android

According to the BLE patent, the size of data in a BLE packet is 47 bytes. However, Android exposes only 20 bytes of data.

  • Why is that? What is transmitted in the remaining 27 bytes?
  • What is the exact format of the Android BLE packet?
  • Is it possible to use more than the 20 bytes in Android BLE packets? Not in multiple packets, though, as in How to send more than 20 bytes data over ble in android?.
like image 556
Augustin Avatar asked Nov 25 '15 11:11

Augustin


People also ask

What is Bluetooth packet format?

For ease of use, Bluetooth defines a single packet format for both advertising and data transmissions. This packet consist of four components: preamble (1 octet), access address (4 octets), Protocol Data Unit – PDU (2-257 octets), and Cyclic Redundancy Check – CRC (3 octets); see Figure 1A.

What is a BLE packet?

Bluetooth® Low Energy Packet Types. The Bluetooth® Low Energy (BLE) Link Layer has only one packet format used for both advertising channel packets and data channel packets: BLE packet Protocol Data Unit (PDU) size in specification v4. 0 and v4. 1 is 2-39 bytes.

What is BLE setting in Android?

Android provides built-in platform support for Bluetooth Low Energy (BLE) in the central role and provides APIs that apps can use to discover devices, query for services, and transmit information. Common use cases include the following: Transferring small amounts of data between nearby devices.


2 Answers

The standard format for the BLE packet in data transmission protocol is:

Command Byte (1 byte) + Device Identification ID (2 bytes) + Data (12-16 bytes) + CheckSum(1 byte)

Command section: These will be hex values that you have to specify according to the type of command (eg. Device Name, Factory Information, Temperature and Humidity data etc.)

Device Identification ID: This will consist of the UUID of the receiving device (it can be 16 bit if its a SIG Group Generated UUID or 128 bit if you are testing)

Data Section: This part will contain all the data that you want to send (it can be between 12 and 16 bytes, although it is recommended that you fix the length of the data packet)

CheckSum: For error correction. You can use a different mechanism but then you will have to adjust your data part accordingly)

You have to define a custom gatt profile and server if you are planning to implement something that doesn't already have an existing profile on the SIG Bluetooth Site.

P.S. Read up more on the device specifications of your external device and also check out the core specs on the bluetooth website. Everything you do must conform to their standards

Alright, Hope this helped.. Cheers!

like image 85
Jobs Avatar answered Oct 27 '22 09:10

Jobs


Basically the BLE packet (delivered as scan record to android APIs) is as far as I know just standard BLE, just as with any other platform.

i.e. it consists of items, and each item consist of 3 items in following order:

  1. 1 byte data length value
  2. 1 byte type as defined in : GATT profile
  3. data, the length is defined by the 1 byte length value

With my tests on BLE I actually see that the scan record that I get is actually longer than I can advertise. So I would assume that you can see beacons & BLE devices advertising with more than 31 bytes even with android devices.

But the BluetoothLeAdvertiser API will only allow you to have 31 bytes in the advertisement scan record you are advertising from android device.

I would not have any good reasoning why the limit is 31 bytes, I just have tested that it is enforced that way.

like image 41
Dr.Jukka Avatar answered Oct 27 '22 09:10

Dr.Jukka