RTL.ExtendedBeaconScanner Sample
This sample shows how to scan for Beacon devices using different scan modes: Standard, Alternative, Eddyston, and Extended.
When selecting the Extended mode, the sample allows you to select the kind of Beacon device to scan: iBeacon, AltBeacon, and Eddystone. The Extended mode allows scanning all different kind of beacon devices simultaneously.
Contents
Location
You can find the ExtendedBeaconScanner sample project at:
- Start | Programs | Embarcadero RAD Studio Athens | Samples and then navigate to:
Object Pascal\Multi-Device Samples\Device Sensors and Services\Bluetooth\Beacons\ExtendedBeaconScanner
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
This sample shows how to use the Extended scan mode to discover all kind of beacons at the same time.
Using the Extended scan mode, the application is able to discover non-registered beacons.
The demo also works with the Standard, Alternative, and Eddyston modes to discover registered beacons.
How to Use the Sample
- Navigate to the location given above and open AllBeaconsScanner.dproj.
- Press F9 or choose Run > Run.
- Select the scan mode: Standard, Alternative, Eddyston, or Extended.
- When selecting Extended as the scan mode, select the kind of beacon to scan: iBeacon, AltBeacon, and Eddystone.
- Select Device Inf. to show information about the discovered devices in the TListView.
- Click SCAN to start scanning for devices.
Configuring the Beacon
You must set the specific parameters for the Beacon device that you want to use with this demo.
Configure the TBeacon component from the service data module:
- Select the TBeacon component.
- In the Object Inspector, go to the MonitorizedRegions property.
- Click Insert to create a new TBeaconRegionItem.
- Select the existing TBeaconRegionItem : 0-TBeaconRegionItem.
- Edit the Major, Minor, and UUID properties from the Object Inspector.
Implementation
This application uses a TBeacon component:
- The Mode property is used to define the scan mode. The value that comes by default is extended.
- The ModeExtended property indicates which kind of beacons to monitor. The values that comes by default are: [iBeacons, AltBeacons, Eddystones].
SCAN Button
The Mode property and the ModeExtended property are defined using two functions:
GetScanningModeChecked
function checks the Scan mode selected in the Scan mode panel of the application. Modes are mutually exclusive.GetKindOfBeaconsChecked
function checks the kind of beacon selected in the Extended mode panel of the application. The Extended mode allows you to scan for several kinds of beacons at the same time.
The SCAN button calls the StartScan method to start monitoring beacons.
STOP SCANNING Button
The STOP SCANNING button calls the StopScan method to stop monitoring beacons.
Device Information
When Device Inf is selected, the TListView is filled with the information of the discovered devices.
The TTimer component is used to print the information in the TListView after the specified time interval, in this case 1 second.
The OnTimer event triggers the Timer1Timer
procedure after the defined time interval.
The Timer1Timer
procedure checks the BeaconList and gets information about the devices.
Uses
- System.Beacon.IBeacon
- System.Beacon.TBeaconList
- System.Beacon.Components.TBeacon
- System.Bluetooth.TBluetoothLEDeviceList
- FMX.ListView.TListView