Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uni.onBluetoothDeviceFound(CALLBACK) API接口得到重复蓝牙名称 #1988

Closed
mworkfun opened this issue Aug 6, 2020 · 1 comment
Closed

Comments

@mworkfun
Copy link

mworkfun commented Aug 6, 2020

在调试安卓APP时,在使用uni.onBluetoothDeviceFound(CALLBACK) 监听寻找到新设备的事件时,第一次开启蓝牙模块监听时得到的蓝牙名称是正确的,在关闭蓝牙,再开启蓝牙模块,接着再监听寻找到新设备的事件时同一个蓝牙会得到2次相同名称的结果。再开启蓝牙模块,接着再监听寻找到新设备的事件时同一个蓝牙会得到3次相同的名称结果......N此,同一个蓝牙就会n次相同的结果。这样是不对的

调用蓝牙步骤:
1、uni.openBluetoothAdapter({}) //开启蓝牙设备
2、uni.getBluetoothAdapterState({}) //获取蓝牙状态
3、uni.startBluetoothDevicesDiscovery({}) //搜索蓝牙
4、uni.onBluetoothDeviceFound(function(devices) {} //监听蓝牙
5、console.log 蓝牙 //终端打印蓝牙名称,就是这里出错,按上面步骤,同一个蓝牙会打印多次
6、uni.stopBluetoothDevicesDiscovery({}) //关闭蓝牙搜索
7、uni.closeBluetoothAdapter({}) //关闭蓝牙设备

图片

@mworkfun
Copy link
Author

mworkfun commented Aug 6, 2020

BitApp.zip这是源码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant