Beacon in Android

Overview

A beacon is a small Bluetooth radio transmitter. It simply broadcasts radio signals that are made up of a combination of letters and numbers transmitted on a regular interval of approximately 1/10 of a second. A beacon uses BLE technology

beacon-image-1

What is BLE?

Bluetooth Low Energy (BLE) also called Bluetooth Smart is a wireless personal area network.The BLE design by Bluetooth SIG. The key difference between classic bluetooth and BLE are :

Classic Bluetooth VS BLE

How beacon works?

A beacon simply broadcasts radio signals at every regular interval of time. It’s like a lighthouse instead of emitting visible light, it broadcasts radio signals.

As per image shown beacon simply transmit a radio signals, once device is in its range. The device will be notified, then we can handle this event as per our requirements.

Components of a beacon

  1. Tiny computer with bluetooth smart connectivity.
  2. Battery
  3. Firmware telling the beacon what it should do exactly.
  4. Sensors

What beacon packet contains?

A beacon generally contains three of fields that are

  1. Beacon unique identifiers
  2. Minor
  3. Major

Let’s take small example to understand what is this, Suppose company X that is located in a city and has many of its branches and each branch contains many departments.
Here,
Beacon unique identifier is equal to company X
Major can be compared to a branch
And minor is equal to a department.

Now when your device gets into beacon’s range it will throw information such as company X is connected with Y branch and Z department.

Types of beacons

There are following type of beacons available in market

  1. iBeacon
  2. Eddystone
  3. AltBeacon, and many more.

1. iBeacon :

Beacon format was introduced in December, 2013. Devices implementing iBeacon protocol can only send one type of signal name UUID.

2. Eddystone :

A new beacon format by google introduced in July, 2015. It is open source and is
available in Github. Devices implementing Eddystone protocol can send three types of signals:

  1. UID
  2. URL
  3. TLM

Example

Here is a code snippet of how to scan a beacon in android. Here, I’m using estimote android SDK to scan beacon.

Add dependencies

Initialize sdk, if you don’t have appId and appToken than pass it blank or null. Create beaconManager object that will help us to connect with beacon. As shown in below code

Now, if you want to scan specific beacon,you need to create a beacon region, in this beacon region you need to pass region name, its UUID, major and minor to its constructor.

To start and stop specific beacon region.

Using beaconManager object, set beacon monitoring listeners. In its listener, there are two overridden methods, onEnteredRegion gives us all nearby scanned beacon list. And another is onExitedRegion which gives us beacon region from where device exists.

Finally when you don’t want to scan any more beacon you need to disconnect using beacon manager object.

Yudiz portfolio

Here, at Yudiz, we have developed apps wherein beacons are used at restaurants and when user’s device gets into the it range, he gets awarded with offers.

Conclusion

Beacon’s future is bright and one can imagine a wide range of possible applications targeting this technology.

mm

Sanju Rajpal Android Developer

I am an Android Developer at Yudiz Solutions Pvt. Ltd. - a leading Android App Development Company. I am passionate about deep testing and provide a Quality Product to the end users.

Comments are closed.

Top