Skip to main content
版本:v3

mstStartScan

API_LEVEL 3.0 开始支持,API 兼容性请参考 API_LEVEL

扫描并发现蓝牙外围设备,可以根据 filter 条件进行过滤。

类型

function mstStartScan(callback: Callback, filter?: Filter): Result

参数

Callback

类型说明
(result: ScanResult, filter?: Filter) => void接收扫描结果回调函数

ScanResult

属性类型说明API_LEVEL
dev_namestring设备名称3.0
dev_addrArrayBuffer设备 MAC 地址,长度 6 字节,建议使用 Uint8Array 视图3.0
rssinumberRSSI 信号强度3.0
service_uuid_arrayArray<string>广播数据中的 Service UUID 数组3.0
service_data_arrayArray<ServiceData>广播数据中的 Service 数据对象数组3.0

ServiceData

属性类型说明API_LEVEL
uuidstringService UUID3.0
service_dataArrayBufferService 数据3.0

Filter

属性类型必填默认值说明API_LEVEL
device_namestring-设备名称3.0
fuzzy_modestring-设备名称匹配是否采用模糊模式3.0
service_uuidstring-Service UUID3.0
service_data_uuidstring-Service 数据 UUID3.0
manufacturer_idnumber-设备商 ID3.0

Result

类型说明
boolean函数调用结果,true 表示成功、false 表示失败

代码示例

import { mstStartScan } from '@zos/ble'

// ...