Showing posts with label BLE. Show all posts
Showing posts with label BLE. Show all posts

Sunday, 19 March 2017

GAP,GATT & Beacon

In the previous article Exploring BLE through nRF51 DK development board, we mentioned briefly about BLE and nRF51-dk. In this article we will be explaining two important concepts which are required to code a bluetooth application.

Before that you should know that bluetooth network model is based on 'proximity networking'  which implies that when two devices come into range of each other, they are capable of establishing a connection.
The advertising takes place in following ways:
1. GAP:

GAP is an acronym of Generic Access Profile, it is used to control the advertising and defines various roles of the devices.It is responsible for your device to be visible to the outer world.

Devices can be divided in the following two roles:
1. Peripheral : These devices are small and are restricted to lesser resources. They are used to connect to much more powerful central devices. eg: heart rate monitoring watches, beacons.
2. Central: These devices are with greater processing power and memory. eg: phones, tablets etc.

There are two ways to send advertising out with GAP. The Advertising Data payload and the Scan Response payload.

Peripheral Devices sets an advertising interval , and sends the advertising data in that duration. The Advertising Data is essential for peripheral device , as it signifies its existence to any nearby listening devices.
Scan Response is sent out by central device , if required for additional information from the peripheral.

During advertising process, a single peripheral advertising data can be scanned by two or more central devices as shown in the figure below.This is known as broadcasting.

                                                              Figure 1 Broadcast Topology

In our project we are using beacons. Please visit the first link to know what are beacons and how do they work.
Beacons advertise themselves by sending  advertising data, which can be of 47 bytes in length and consist of :
1 byte preamble
4 byte access address
2-39 bytes advertising channel PDU
3 bytes CRC

                                                                    Figure 2 Advertised Data

As shown in the figure above PDU contains header, MAC and Data upto 31 bytes.
The Data of 31 bytes contains Beacon prefix, Proximity UUID , Major , Minor and TX power as shown in the figure.
                                                               Figure 3 Inside the Data Bytes

Our task was to scan the beacons using nRF51-dk. We used the example code BLE_Observer , which scans the beacons and returns the values of MAC address, RSSI, Scan response , Advertising type,Proximity UUID , Major , Minor and TX power .

The main purpose of peripheral to advertise is to establish a connection with the central device.
Once the connection occurs advertising process ends and we use GATT services and characteristics to communicate in both directions.

BLE devices can operate in a non-connectable advertisement-only mode (where all the information is contained in the advertisement), but they can also allow connections (and usually do).
In our project , we are using only GAP and we have used it in our scanner.

2. GATT:

GATT is an acronym for the Generic Attribute Profile, and it defines the way that two Bluetooth Low Energy devices transfer data back and forth using concepts called Services and Characteristics.
As mentioned above, GATT comes into play once a connection is established.
Now comes the interesting part, as said peripheral device can be scanned by two or more central devices. But once a connection is established , peripheral cannot advertise anymore and communicates with a single central device.
But a central device is capable of establishing connection with two or more peripheral devices. This kind of topology is called Connected Network Topology.
Figure 4 Connected Topology
An important concept which comes into play in GATT is server/client relationship.
We would recommend you to visit the second link  mentioned below to understand the concept.

Useful/ Recommended Links:
http://www.pointrlabs.com/blog/beacons-everything-you-need-to-know/
https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt
 

Thursday, 16 March 2017

Exploring BLE through nRF51 DK development board

We are currently working on nRF51DK, a single-board development kit for Bluetooth low energy, ANT  and 2.4 GHz proprietary applications by Nordic Semiconductors.

                                                       Figure 1 nRF51DK development kit content

BLE as mentioned, stands for Bluetooth Low Energy, and is also known as Bluetooth Smart a subset of Bluetooth 4.0 specification. It is widely used in developing IoT devices as it is a good platform due to its less power consumption,cost and reduced data rate in comparison to Bluetooth Classic.
BLE operated devices work for longer periods on power sources such as coin cell batteries like iBeacons.
We have used beacons in our application and we will be covering it in the upcoming posts.
   
The support for Bluetooth 4.0 and Bluetooth Low Energy is available on most major platforms as of the versions listed below:
  •     iOS5+ (iOS7+ preferred)
  •     Android 4.3+ (numerous bug fixes in 4.4+)
  •     Apple OS X 10.6+
  •     Windows 8 (XP, Vista and 7 only support Bluetooth 2.1)
  •     GNU/Linux Vanilla BlueZ 4.93+

nRF51DK:

We are using BLE in our final year project and for that we are using nRF51DK board.The board is fitted with the nRF51422 chip and on board interface MCU as shown in the figure below.
nRF51422 is ARM Cortex- M0 32 bit processor, the MCU is used for sending the hex file to the on board bluetooth chip (referring the ARM Cortex processor). The board has Debug In terminal pins for programming the on board bluetooth chip using another MCU and Debug Out terminal pins to program other bluetooth chip modules using the on board MCU other than the on board bluetooth chip.
These options are quite helpful in long run and for varied applications. 
The project is built on ARM processor and mbed as the compiler. We can also use Keil, but for that you need to download requisite libraries.
mbed is easy to use online compiler for beginners and hobbyists who wish to do projects on ARM processors. There are lot of other boards available, along with their libraries.
Do visit the links attached at the end to explore more additional features of board as well as mbed. 



                                                                Figure 2 Block diagram for nRF51DK 

In order to begin working with BLE, there are two important concepts one must know:
1. GAP Advertising
2. GATT
We will cover these two in the next article along with application of scanner for beacons. 

Useful Links: