【发布时间】:2020-07-29 08:58:41
【问题描述】:
我目前正在使用 polidea 的 react-native-ble-plx 库进行 BLE 扫描。 我不想让它继续扫描,我只想在指定的时间限制后捕获那些扫描的。 有没有办法做到这一点?
代码:
export const scan = function scan() {
const subscription = DeviceManager.onStateChange((state) => {
if (state === 'PoweredOn') {
DeviceManager.startDeviceScan(null, null, (error, device) => {
if (error) {
console.log('error', error);
}
if (device !== null) {
console.log('device found ----> [id,name]', device.id, device.name);
}
});
subscription.remove();
}
}, true);
};
输出: Output Image
【问题讨论】:
标签: bluetooth-lowenergy beacon scanning