System.Bluetooth.TBluetoothLEManager.StartDiscovery

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function StartDiscovery(Timeout: Cardinal; const AFilterUUIDList: TBluetoothUUIDsList = nil; ForceConnect: Boolean = False): Boolean; overload;
function StartDiscovery(Timeout: Cardinal; const ABluetoothLEScanFilterList: TBluetoothLEScanFilterList): Boolean; overload;

C++

bool __fastcall StartDiscovery(unsigned Timeout, TBluetoothUUIDsList* const AFilterUUIDList = (TBluetoothUUIDsList*)(0x0), bool ForceConnect = false)/* overload */;
bool __fastcall StartDiscovery(unsigned Timeout, TBluetoothLEScanFilterList* const ABluetoothLEScanFilterList)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.Bluetooth.pas
System.Bluetooth.hpp
System.Bluetooth TBluetoothLEManager

Description

Starts a discovery operation to find remote devices using Bluetooth Low Energy.

The first overloaded method of StartDiscovery accepts the following parameters:

  • Timeout determines how much time you want to spend discovering remote devices using Bluetooth Low Energy.
  • AFilterUUIDList is an optional list of one or more UUIDs of Bluetooth GATT services. If you provide this list, the manager ignores the remote devices that do not advertise at least one of the specified services.
  • If ForceConnect is True and you provide a value for AFilterUUIDList, the manager connects to every discovered remote device to obtain a complete list of the services that each remote device provides, so that StartDiscovery does not ignore devices that do provide one of the specified services but do not advertise it.

The second overloaded method of StartDiscovery accepts the following parameter:

  • ABluetoothLEScanFilterList represents a list with the BLE scan filters that contain specific data fields about the BLE devices you want to scan for.

The OnDiscoverLeDevice event occurs once for each discovered remote device. When the discovery operation finishes, the OnDiscoveryEnd event occurs. OnDiscoveryEnd provides a list of discovered remote devices.

When a device is ignored because it does not advertise or provide one of the specified services:

  • The OnDiscoverLeDevice event does not occur for that remote device.
  • The remote device is not part of the list of remote devices that the event handler of OnDiscoveryEnd receives.

StartDiscovery returns True if the discovery starts successfully, or False if something prevents the discovery from starting.

StartDiscovery calls StartDiscovery of the current adapter.

Attention: If using iOS 13.3.1 and 13.3.0, the Bluetooth LE device discovery methods TBluetoothManagerLE.StartDiscovery and TBluetoothLE.DiscoverDevices cause the mobile app to close without notice.

Platform Support

Platform Notes

32-bit Windows
64-bit Windows

OS X

  • OnDiscoveryEnd always occurs some time after the specified Timeout, never before.
  • Always returns True.

iOS

  • OnDiscoveryEnd always occurs some time after the specified Timeout, never before.
  • Always returns True.

Android

  • OnDiscoveryEnd always occurs after the specified Timeout, never before.

See Also