How to Manage iBeacon Scanning using Mesosfer – Part 1

This tutorial is about How to manage iBeacon scanning using Mesosfer.

Table of Contents

  1. 1. iBeacon
    1. 1.1. What is iBeacon?
    2. 1.2. Cubeacon SDK for scanning beacon
    3. 1.3. Beacon region
    4. 1.4. Ranging beacons
    5. 1.5. Monitoring regions
  2. 2. Mesosfer – Beacon Module
    1. 2.1. Storyline
    2. 2.2. Presence
    3. 2.3. Notification
    4. 2.4. Microlocation
  3. 3. Tutorial
    1. 3.1. Create Mesosfer App
    2. 3.2. Create project
    3. 3.3. Installing library
    4. 3.4. Intialize Cubeacon & Mesosfer SDK

Integrating Cubeacon and Mesosfer SDK for Android. This tutorial describes :

  1. How to manage beacon scanning in Android applications.
  2. Demonstrates how to use existing Beacon module in Mesosfer SDK.
  3. It also demonstrates the usage of the Beacon analytic which allows developers to send log asynchronously.

The tutorial is based on Android Studio 2.2, Java 1.8 and Android SDK 4.3. Testing device using Android phone with version 4.3 Jelly Bean and Bluetooth Low Energy enabled and some beacon.

1. iBeacon

1.1. What is iBeacon?

iBeacon is a protocol developed by Apple and introduced at the Apple Worldwide Developers Conference in 2013. Various vendors have since made iBeacon-compatible hardware transmitters – typically called beacons – a class of Bluetooth low energy (BLE) devices that broadcast their identifier to nearby portable electronic devices. The technology enables smartphones, tablets and other devices to perform actions when in close proximity to an iBeacon.

iBeacon is an exciting technology enabling new location awareness possibilities for apps. Leveraging Bluetooth Low Energy (BLE), a device with iBeacon technology can be used to establish a region around an object. This allows a smartphone to determine when it has entered or left the region, along with an estimation of proximity to a beacon . There are both hardware and software components to consider when using iBeacon technology.

An iBeacon advertisement provides the following information via Bluetooth Low Energy:

Field Size Description
UUID 16 bytes Application developers should define a UUID specific to their app and deployment use case.
Major 2 bytes Further specifies a specific iBeacon and use case. For example, this could define a sub-region within a larger region defined by the UUID.
Minor 2 bytes Allows further subdivision of region or use case, specified by the application developer.

1.2. Cubeacon SDK for scanning beacon

Cubeacon SDK for Android is a library to allow interaction with any beacons. The SDK system requirements are Android 4.3 or above and Bluetooth Low Energy.

Cubeacon SDK allows for:

  • Beacon ranging (scans beacons and optionally filters them by their properties).
  • Beacon monitoring (monitors regions for those devices that have entered/exited a region).

You can read more about Cubeacon SDK for Android here.

1.3. Beacon region

Beacon region is like a filter or a regular expression. Each beacon is identified by three values:

  1. Proximity UUID, most commonly represented as a string, e.g. CB10023F-A318-3394-4199-A8730C7C1AEC.
  2. Major, an unsigned short integer, i.e., an integer ranging from 1 to 65535, (0 is a reserved value).
  3. Minor, also an unsigned short integer, like the major number.

1.4 Ranging beacons

Ranging beacons is an actions that triggered based on proximity to a beacon; works only when the app is running (e.g., it’s displayed on screen, or running in the background in response to a monitoring event, etc.)

1.5. Monitoring regions

Monitoring regions is an actions that triggered on entering/exiting region’s range; works no matter whether the app is running or suspended. It’s important to remember that Monitoring allows you to scan for beacon regions, while Ranging is for interacting with individual beacons.

2. Mesosfer, Beacon Module

Beacon module is one of Mesosfer module that has specific feature to manage beacon activities.

2.1. Storyline

This module used for showing a “story” when beacons are detected or in range e.g. museum, merchant shop, etc. Y0u can manage what “story” that need to show to the end users when detected beacon e.g. some alert text or notification, displaying an image campaign, playing a video campaign or maybe open some website. You can also choose when the “story” must displayed based on beacon’s event :

  • Enter, triggered when user entering region of a beacon
  • Exit, triggered when user exiting region of a beacon
  • Immediate, triggered when user range approximately <1 meter from beacon
  • Near, triggered when user range approximately within 1-3 meters from beacon
  • Far, triggered when user range approximately >3 meters from beacon

Besides, you can select what days to show when “story” was triggered. By using a storyline, you can manage multiple beacon’s “story”.

2.2. Presence

This module can be used to tracking any check-in and check-out data e.g. employee attendance, student presence, etc.

2.3. Notification

This module is the simple version of storyline, it can only manage a beacon for each notification e.g. show a greeting when user entering shop.

2.4. Microlocation

This module can be used for track indoor location using a mapped beacon in an area.

3. Tutorial

3.1. Create Mesosfer app

First, you need to login or register to Mesosfer Cloud. Then create an app with type Beacon :


Execute the button Make It!.

3.2. Create project

Create the project using package com.eyro.mesosfer.beacon with the activity called SplashActivity. Create another activity called MainActivity.

3.3. Installing library

Before we initialize the SDKs, we need to install Cubeacon & Mesosfer library.

Cubeacon SDK for Android :

  • Download the latest SDK from here.
  • Copy cubeacon-x.y.z.aar file into libs folder.

Mesosfer SDK for Android :

  • Download the latest SDK from here.
  • Copy MesosferSDK-Android-x.y.z.aar file into libs folder.

On your build.gradle within app module, add this lines below before dependencies tag :

Then add this code below on dependencies :

3.4. Initialize Cubeacon & Mesosfer SDK

To initialize Cubeacon and Mesosfer SDK, we need to create application class called MesosferApp.

Change Mesosfer application id and client key with your own credentials. Don’t forget to add your custom application class into AndroidManifest.xml

It’s done. We will continue this tutorial on Part-2.

Lead Mobile Software Engineer. Having more than 8 years in IT Consultant. Love working with new mobile platform technology. Expert in Android and iOS Mobile Development.