RTL.BeaconProximityColors Sample

From Appmethod Code Examples
Jump to: navigation, search

The sample shows how to implement an application for detecting changes on the proximity property of a detected Beacon. The sample indicates if a new beacon has gone into the Inmediate area. If a change is detected, the form changes its background color.

To have this sample working and showing changes, you need a Bluetooth LE beacon compatible to one of the available types: iBeacon or AltBeacon.

Location

You can find the ColorBeaconProximity sample project at:


Description

This sample searches beacons that are advertising its manufacturer data according to one of the available types. This sample is developed using the Beacon framework directly instead of the TBeacon component. In Using Beacons you can find more information about how to implement a beacon application.

BeaconProximityColor.png

How to Use the Sample

  1. Navigate to the location given above and open:
    • Object Pascal: ColorsBeaconProximity.dproj.
    • C++: ColorsBeaconProximityCPP.cbproj.
  2. Select as a platform, a device with a bluetooth LE sensor.
    Note: See Using Bluetooth for more information about client platform support for Bluetooh LE.
  3. Press F9 or choose Run > Run.
  4. Click Start to start to detect beacons.
  5. Click Stop to stop to detect beacons.

Implementation

When the form is initially shown, the application initializes and configures everything needed for receiving beacons:

  • Gets an instance of the TBeaconManager for the beacon type. The sample is configured for Standard (iBeacon), you must get the instance for the type of your beacon.
  • Registers the event OnBeaconProximity.
    Note: The OnBeaconProximity event occurs every time the proximity parameter of a detected beacon changes.
  • Registers the beacons you want to detect.
    Note: The sample is registered for the UUID {B9407F30-F5F8-466E-AFF9-25556B57FE6D}. You must register the UUID of your own beacons.
  • Configures some parameters of the TBeaconManager:
  • And starts scanning beacons.

Once the OnBeaconProximity event occurs, if the new proximity parameter is Inmediate, the color of the form changes. The color is associated to the beacon which proximity value changes. In this sample, the beacon is identified by its Major ID, you must use the Major ID and/or Minor ID of your beacon instead.

Uses

See Also

Personal tools