public class BleCentralManager extends Object
Use BleCentralManagerCallback as a parameter to construct BleCentralManager instances.
Customize the callback in BleCentralManagerCallback.
Use startScan(java.util.List<ohos.bluetooth.ble.BleScanFilter>) to start scanning.
Use stopScan() to stop scanning.
| 构造器 | 说明 |
|---|---|
BleCentralManager(Context context,
BleCentralManagerCallback callback) |
A constructor used to create a
BleCentralManager instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
List<BlePeripheralDevice> |
getDevicesByStates(int[] states) |
Obtains the list of devices in the specified status.
|
void |
startScan(List<BleScanFilter> filters) |
Starts scanning for specified BLE devices with filters.
|
void |
startScan(List<BleScanFilter> filters,
int dutyRatio,
int matchingMode) |
Starts scanning for specified BLE devices with filters, duty ratio, and matching mode.
|
void |
startScan(List<BleScanFilter> filters,
int dutyRatio,
int matchingMode,
long time) |
Starts scanning for specified BLE devices with filters, duty ratio, matching mode and delay report time.
|
void |
stopScan() |
Stops
BleCentralManager from scanning devices. |
public BleCentralManager(Context context, BleCentralManagerCallback callback)
BleCentralManager instance.public void startScan(List<BleScanFilter> filters)
filters - Indicates the list of filters used to filter out specified devices.public void startScan(List<BleScanFilter> filters, int dutyRatio, int matchingMode)
filters - Indicates the list of filters used to filter out specified devices.dutyRatio - Indicates the duty ratio.matchingMode - Indicates the matching mode.public void startScan(List<BleScanFilter> filters, int dutyRatio, int matchingMode, long time)
filters - Indicates the list of filters used to filter out specified devices.dutyRatio - Indicates the duty ratio.matchingMode - Indicates the matching mode.time - Indicates the delay report time.public void stopScan()
BleCentralManager from scanning devices.public List<BlePeripheralDevice> getDevicesByStates(int[] states)
states - Indicates the connection status, which can be ProfileBase#STATE_DISCONNECTED,
ProfileBase#STATE_CONNECTING, ProfileBase#STATE_CONNECTED,
or ProfileBase#STATE_DISCONNECTING.BlePeripheralDevice matching the specified status.