中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit'; function onReceiveEvent(data: Array<ble.ScanResult>) { console.info('BLE scan device find result = ' + JSON.stringify(data)); } try { ble.on("BLEDeviceFind", onReceiveEvent); let scanFilter: ble.ScanFilter = { deviceId:"XX:XX:XX:XX:XX:XX", name:"test", serviceUuid:"00001888-0000-1000-8000-00805f9b34fb" }; let scanOptions: ble.ScanOptions = { interval: 500, dutyMode: ble.ScanDuty.SCAN_MODE_LOW_POWER, matchMode: ble.MatchMode.MATCH_MODE_AGGRESSIVE } ble.startBLEScan([scanFilter], scanOptions); } catch (err) { console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); }