RTL.BeaconDevice Sample
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:
- Start | Programs | Embarcadero RAD Studio 10 Seattle | Samples and then navigate to either:
Object Pascal\Multi-Device Samples\Device Sensors and Services\Bluetooth\Beacons\Beacon Device
CPP\Multi-Device Samples\Device Sensors and Services\Bluetooth\Beacons\Beacon Device
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RADStudio_Seattle/Object%20Pascal/Multi-Device%20Samples/Device%20Sensors%20and%20Services/Bluetooth/Beacons/Beacon%20Device
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RADStudio_Seattle/CPP/Multi-Device%20Samples/Device%20Sensors%20and%20Services/Bluetooth/Beacons/Beacon%20Device
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
- Navigate to one of the locations given above and open:
- Delphi: BeaconDeviceDemo.dproj.
- C++: BeaconDevDemo.cbproj.
- Press F9 or choose Run > Run.
- 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 indBm
.
- Click the
- Click the
BtnEnableBeacon
button: Enable Beacon enables theBeaconDevice1
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.