Bluetooth Low Energy (BLE)

Don’t you think Bluetooth plays a significant role in making the smart phones smart? So let’s talk about something smarter i.e. Bluetooth Smart or BLE. As far as the BLE or the Bluetooth low energy is concerned it is not just a feature it’s a new technology

it was first proposed by NOKIA in 2006 with the name WIBREE. And now the devices which are equipped with BLE are called as Bluetooth Smart devices and the devices which has both Bluetooth classic and the BLE are called as Bluetooth Smart Ready devices.

Bluetooth

Bluetooth

 

It basically focuses on lowering the battery use and making the battery use up to 10 times lesser than that in the classic Bluetooth devices. Making the Bluetooth feature possible in the devices which run on battery without charging for years even, like watches, remote control, health devices etc.

And it is the assumption that the BLE will be available in 90% of the smart phones by 2018.

 

In android it is available from API 18 (android 4.3) onwards, the nexus 4 and the nexus 7 are the first two Bluetooth Smart Ready devices. The android 4.3 provides API that apps can use to discover devices, query for services, and read/write characteristics.

Let’s have a look at how does BLE work?

 

BLE is based on specification called GATT i.e. Generic Attribute Profile and GATT communicates using attribute protocol ATT.

 

ATT transfers data in the form of attributes and performs operations over the attributes. The basic type of attributes is descriptors and characteristics descriptors are the attributes which are description tag for another piece of data.The characteristics consist of value and zero or more descriptors.

 

Characteristics then can be grouped together to form a service which then the BlE device can advertise to other devices.Either of the BLE devices can act as a client or server it depends upon which device is making the characteristics available to the other.

BLE Terminology

BLE Terminology

It’s just an outline to give you an idea about the process. But let me tell you that the communication between the BLE and the Bluetooth Classic has not been made possible till now.

 

Now let’s have a brief look as to how can the API be implemented into the android devices, here is an example of simply scanning the BLE devices, just a guidance for further implementation.

Programmatic Implementation in Android: 

There should be declaration of permission in the android manifest if you want to use the Bluetooth feature of the device with your application.

<uses-permission android:name=“android.permission.BLUETOOTH” />
<uses-permission android:name=“android.permission.BLUETOOTH_ADMIN” />

the  BLUETOOTH_ADMIN permission is provided if you want to initiate the discovery of the device or manipulate the settings.

And the BLUETOOTH permission is required if you are using the BLUETOOTH_ADMIN and hence the Bluetooth feature of the device and if you want to declare that the app is for the BLE supporting devices only you need to add.

<uses-feature
android:name=“android.hardware.bluetooth_le”
       android:required=“true” />

In your android manifest and if you want to declare that the app can be used in the BLE non supporting devices too you need to set the android:required=“true” as false.

 

//instance of the BluetoothAdapter class and calling of the method to start the scanning
	mBluetoothAdapter.startLeScan(mLeScanCallback);

	//callback handling
	private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback(){

	public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord){
	//handle discovered devices
	}
}

And for broader level implementation of the BLE in android app you can have a look here
http://developer.android.com/guide/topics/connectivity/bluetooth-le.html 

Thank you for your time 🙂

 

Written By: Trayambak Mishra, Software Developer, Mindfire Solutions

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s