mstStartScan
Start from API_LEVEL
3.0
. Please refer to API_LEVEL.
Scan and discover Bluetooth peripherals, which can be filtered according to filter conditions.
Type
function mstStartScan(callback: Callback, filter?: Filter): Result
Parameters
Callback
Type | Description |
---|---|
(result: ScanResult, filter?: Filter, timeout?: Timeout) => void | Callback function for receiving scan results |
ScanResult
Property | Type | Description | API_LEVEL |
---|---|---|---|
dev_name | string | Device name | 3.0 |
dev_addr | ArrayBuffer | Device MAC address, 6 bytes long, Uint8Array view recommended | 3.0 |
rssi | number | RSSI Signal Strength | 3.0 |
service_uuid_array | Array<string> | Service UUID array in broadcast data | 3.0 |
service_data_array | Array<ServiceData> | Array of Service Data Objects in Broadcast Data | 3.0 |
ServiceData
Property | Type | Description | API_LEVEL |
---|---|---|---|
uuid | string | Service UUID | 3.0 |
service_data | ArrayBuffer | Service data | 3.0 |
Filter
Property | Type | Required | DefaultValue | Description | API_LEVEL |
---|---|---|---|---|---|
device_name | string | N | - | Device name | 3.0 |
fuzzy_mode | string | N | - | Whether to use fuzzy mode for device name matching | 3.0 |
service_uuid | string | N | - | Service UUID | 3.0 |
service_data_uuid | string | N | - | Service data UUID | 3.0 |
manufacturer_id | number | N | - | Manufacturer ID | 3.0 |
Timeout
Property | Type | Required | DefaultValue | Description | API_LEVEL |
---|---|---|---|---|---|
duration | number | N | - | Scanning duration, in seconds. Scanning automatically stops when the given duration is reached | 3.0 |
on_timeout | () => void | N | - | Callback function after scanning stops | 3.0 |
Result
Type | Description |
---|---|
boolean | The result of the function call, true means success, false means failure |
Example
import { mstStartScan } from '@zos/ble'
// ...