RTL.BeaconComponent Sample

From Appmethod Code Examples
Jump to: navigation, search

The sample shows how to implement and application for detecting beacons using the TBeacon component.

Location

You can find the BeaconComponent sample project at:

Description

This sample uses the TBeacon component for scanning beacons. Just pushing the Start button, the sample detects the configured beacons showing the results on a TMemo control which is included on the Form1.

As it is explained in Using Beacons the beacons must be registered for detecting them. The sample is initially configured for:

  • Detecting Alternative beacons, configured in the Mode property of the TBeacon component.
  • The beacons to be detected must be added in the MonitorizedRegions property of the TBeacon component. This sample includes a default region. You must add the regions of the beacons you want to detect, specifying the UUID, Major, and Minor.

How to Use the Sample

  1. Navigate to the location given above and open:
    • Object Pascal: BeaconComponent.dproj.
    • C++: BeaconComponentCPP.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.

Implementation

The sample application defines three event handlers:

  • Beacon1BeaconEnter: This event handler occurs when a new beacon is detected. The event handler adds a new entry to the Memo1 TMemo control with the information of the detected beacon.
  • Beacon1BeaconExit: This event handler occurs when a beacon becomes unreachable. The event handler adds a new entry to the Memo1 TMemo control including the beacon data.
  • Button1Click: This event handler occurs when the Button1 is pressed. The event handler sets the Enabled property to start scanning beacons.

Uses

See Also