RTL.SimpleBeacon Sample

From RAD Studio Code Examples
Jump to: navigation, search

Location

You can find the Simple Beacon sample project at:

Description

This is a sample that shows the use of the Beacon API to search for nearby beacons.

The application uses the following controls:

  • Button1: Fires the Button1Click event handler.
  • Beacon1: The control that implements the TBeacon component.
  • Memo1: Displays the messages about discovered beacons.

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: BeaconComponent.dproj.
    • C++: BeaconComponentCPP.cbproj.
  2. Press F9 or choose Run > Run.
  3. Click the Start button to start searching for beacons.

The application displays the following information in the Memo1 control:

  • When a beacon comes into range:
    • "New Beacon"
    • UUID: The GUID identifier of the beacon.
    • Major: The Major identifier of the beacon.
    • Minor: The Minor identifier of the beacon.
    • Current Beacons count: The total number of beacons in range.
  • When a beacon goes out of range:
    • "Beacon exited"
    • UUID: The GUID identifier of the beacon.
    • Major: The Major identifier of the beacon.
    • Minor: The Minor identifier of the beacon.
    • Current Beacons count: The total number of beacons in range.

Implementation

This application uses a TBeacon component to:

  • Periodically search for nearby beacons and check whether the discovered beacons are still in range.
  • Display information when a beacon comes into range.
  • Display information when a beacon goes out of range.

Main Form

The application defines the following event handlers:

  • Button1Click: Enables the Beacon1 control.
  • Beacon1BeaconEnter: The event handler for the OnBeaconEnter event. Displays the information about the beacon that comes into range.
  • Beacon1BeaconExit: The event handler for the OnBeaconExit event. Displays the information about the beacon that goes out of range.

Uses

See Also