RTL.BeaconDevice Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample shows how to use the BeaconDevice API in order to configure a BLE device to operate as a Beacon device.

Location

You can find the BeaconDevice sample project at:

Description

This sample shows how to configure a TBeaconDevice component so that your BLE device operates as a Beacon device. After the component is configured, your device can start advertising data for proximity purposes.

The application provided with this sample allows you to introduce custom settings for a BeaconDevice.

You can either set random or custom values for the following advertising data parameters:

  • UUID: Identifies unequivocally your device as a beacon, or as part of a group of beacons.
  • Major: Specifies subdivisions within a group of beacons defined by UUID.
  • Minor: Specifies further sub-regions inside Major subdivisions.
  • TxPower: Specifies the power transmission of the beacon. It represents the RSSI value expected at 1m distance to the beacon. You can use this value later for calibration purposes.

Note: For information about platform support, see platform support.

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: BeaconDeviceDemo.dproj.
    • C++: BeaconDevDemo.cbproj.
  2. Press F9 or choose Run > Run.
  3. In order to specify values for the advertising data parameters, you can either:
    • Click the BtnRandom button: Set Random sets random values for UUID, Major and Minor. TxPower is set to its default value.
    • Enter your custom values in the following TEdit controls:
    • EdtBeaconUUID: Enter a UUID value.
    • EdtBeaconMajor: Enter a Major value.
    • EdtBeaconMinor: Enter a Minor value.
    • EdTxPower: Enter a TxPower value in dBm.
  4. Click the BtnEnableBeacon button: Enable Beacon enables the BeaconDevice1 so that it can start advertising data with the specified parameters.

Implementation

This application uses a TBeaconDevice that can be configured by entering values in the following TEdit controls:

  • EdtBeaconUUID
  • EdtBeaconMajor
  • EdtBeaconMinor
  • EdTxPower

The application defines the following event handlers so that the entered values are set up in the component:

  • BtnRandomClick: Generates random values for the parameters specified above.
  • BtnEnableBeaconClick:
    • Checks whether the entered UUID value is valid.
    • Sets the entered values to the BeaconDevice1 component.
    • Enables the BeaconDevice1 so that it can start advertising data.

Uses

See Also

Personal tools
Assistance