问题描述
使用react-native-ble-plx库,每当我扫描设备时,我都会获得MAC地址,该MAC地址在每次打开和关闭附近的设备时都会更改,因此,如果设备存在或不存在,我应该如何比较?诸如device.name,device.localName的字段为null。以下是我扫描附近设备的代码。
const App = () =>{
const DeviceManager = new BleManager();
const subscription = DeviceManager.onStateChange((state) =>{
if(state === 'PoweredOn'){
console.log('I am powered On');
scan();
subscription.remove();
}
},true)
const scan = () =>{
DeviceManager.startDeviceScan([],null,(error,device)=>{
console.log('Scanning');
if(device === null){
console.log(error);
}
if(device !== null){
console.log('found devices');
console.log(device.id);
console.log(device.name);
}
})
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)