The sample shows how to implement and application for detecting beacons using the TBeacon component.
You can find the BeaconComponent sample project at:
- Start | Programs | Appmethod 1.16 | Samples and then navigate to:
- CPP\Mobile Samples\Device Sensors and Services\Bluetooth\Beacons\Beacon component\
- Object\Mobile Samples\Device Sensors and Services\Bluetooth\Beacons\Beacon component\
- Subversion Repository for Object Pascal: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE8//Object%20Pascal/Mobile%20Samples/Device%20Sensors%20and%20Services/Bluetooth/Beacons/Beacon%20component
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE8//CPP/Mobile%20Samples/Device%20Sensors%20and%20Services/Bluetooth/Beacons/Beacon%20component
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
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
- Navigate to the location given above and open:
- Object Pascal: BeaconComponent.dproj.
- C++: BeaconComponentCPP.cbproj.
- 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.
- Press F9 or choose Run > Run.
- Click Start to start to detect beacons.
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
Memo1TMemo 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
Memo1TMemo control including the beacon data.
Button1Click: This event handler occurs when the
Button1is pressed. The event handler sets the Enabled property to start scanning beacons.