RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
C++

Building Proximity Aware Application with RAD Studio XE8

RAD Studio XE8 provides you with the tools to rapidly design, build, and deploy connected apps that deliver innovative IoT solutions.

The new Beacon component makes it easy to add proximity awareness to your applications.

Beacons Proximity Stadium Large

Two beacon formats are available: iBeacon and AltBeacon.

  • iBeacon is a format defined by Apple. When working with iBeacons, select the Standard Mode available for the TBeacon component. 
  • AltBeacon is an open format, known as Alternative beacon. The full specifications can be found on http://altbeacon.org. When working with AltBeacons, select the Alternative Mode for the TBeacon component.  

Bluetooth Low Energy devices in advertising mode send the Advertising Data repeatedly over radio in different AD type structures. 

One of the AD types in the Advertising Data is the “Manufacturer Specific Data” which is utilized for beacons. The data included in the “Manufacturer Specific Data” is:

  • UUID: A unique identifier which identifies a group of beacons, for example, the beacons of a specific company.
  • MajorID, MinorID: Identifies regions inside a specific UUID. MajorID identifies a sub-region within a larger region defined by an UUID. The MinorID specifies further subdivision within a MajorID.
  • TxPower: The TxPower is the measured power from 1 meter of distance. With TxPower and the Received Signal Strength Indicator (RSSI), the approximate distance to a Beacon is calculated.

iBeacon requires both major and minor numbers to be defined. 

Major numbers are designed to identify a group while minor numbers are designed to identify an individual beacon.

TBeacon has a property called MonitorizedRegions that lets you define the UUID, minor and major numbers for your beacons. Generally speaking, all your beacons should use the same UUID. You would then change the Major and Minor values based on your needs. 

MonitorizedRegionsProperty

If you set the Major and Minor values to -1, it indicates that you want to track all beacons using that same UUID. You can then programmatically define the Major and Minor numbers and execute actions depending on which beacon was detected.

A good practice would be to store the beacon information in a database. Then, the client app running on the user’s smartphone or tablet can connect to the same database.

Upon detecting the beacon in your application, you will receive an event. In the event, you can read the major and minor values and then fire another action, such as displaying a location specific message as the user approaches a specific beacon.

Below is a sample use case showing how major and minor numbers for beacons can be used in a real world scenario to identify them. 

Tradeshow Beacon Use Case:

   4 exhibit halls, so major numbers of 1 – 4 are being used to identify the 4 exhibit halls

–  Each exhibit has 20 booths, so each beacon is assigned a minor number of 1 to 20

–   This means that there are a total of 80 beacons used in this scenario 

 BeaconDataTable1

 

  
Beacons are supported on Android, iOS and OS X. Beacons are not supported on Windows since
the beacon advertising data is not accessible on Windows.
 
Detailed information on setting permissions to use beacons etc. can be found on our docwiki:

Here is a quick code example that finds nearby beacons:

BeaconDiscoveryDemo

You can download the demo here. This is the same demo that I showed during the XE8 launch webinar today. It has UUIDs predefined for the following manufacturers:

  • Estimote 
  • Radius Networks
  • BLE Home
  • EM Microelectronic

If you are using beacons by a different manufacturer or are using custom UUIDs, you can add/edit them via the MonitorizedRegions property on TBeacon. 

You can also watch the beacon proximity skill sprint here: https://www.youtube.com/watch?v=_VWFk3RTW8A 

Several different beacon focused demo projects for Delphi and C++ are also installed with RAD Studio XE8. You can access them by going to:

C:UsersPublicDocumentsEmbarcaderoStudio16.0SamplesObject PascalMobile SamplesDevice Sensors and ServicesBluetoothBeacons

C:UsersPublicDocumentsEmbarcaderoStudio16.0SamplesCPPMobile SamplesDevice Sensors and ServicesBluetoothBeacons

 

Download a Free RAD Studio XE8 Trial today: http://www.embarcadero.com/downloads 

 

 


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Learn More About Upgrading

About author

Director of Product Management, Developer Tools Idera, Inc.
Related posts
C++DelphiRAD Studio

Learn How To Use WinRT In Your Native Windows Delphi And C++ Builder Apps

C++News

Using Python4Delphi with C++Builder (webinar)

C++CodeRAD Studio

Learn About The Initialization Of Class Objects By Rvalues In C++ Windows Development

C++CodeRAD Studio

Learn How To Use C++ Variadic Templates For Windows Development With C++Builder

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES