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

Scan can't find the device #5

Closed
yh4922 opened this issue Dec 15, 2021 · 4 comments
Closed

Scan can't find the device #5

yh4922 opened this issue Dec 15, 2021 · 4 comments

Comments

@yh4922
Copy link

yh4922 commented Dec 15, 2021

After checking the Bluetooth open state, call the flutterblueelves.instance.startscan (5000) scanning device, but there is no result, the terminal outputs the log

I/flutter (27789): ble status:true,  start scaning
D/BluetoothAdapter(27789): isLeEnabled(): ON
D/BluetoothLeScanner(27789): could not find callback wrapper
D/BluetoothAdapter(27789): isLeEnabled(): ON
D/BluetoothLeScanner(27789): onScannerRegistered() - status=0 scannerId=7 mScannerId=0
2
D/BluetoothAdapter(27789): isLeEnabled(): ON
D/BluetoothLeScanner(27789): could not find callback wrapper

I don't know what the reason is caused, permissions or configuration files❓

@pineappleoOilPrince
Copy link
Owner

Did you call listen() after startscan?
Such as: FlutterBlueElves.instance.startScan(5000).listen((event){})

@yh4922
Copy link
Author

yh4922 commented Dec 15, 2021

我是这样调用的

/// 扫描BLE设备
static void scanBle (void Function(ScanResult) onData) {
  FlutterBlueElves.instance.startScan(5000).listen(onData);
}

@pineappleoOilPrince
Copy link
Owner

那么应该是因为你的定位权限和定位功能没有打开,你可以扫描前调用FlutterBlueElves.instance.androidCheckBlueLackWhat()来检测android端是否没有打开上述功能,如果没有就调用下面三个方法来打开对应功能
FlutterBlueElves.instance.androidApplyLocationPermission((result){})
FlutterBlueElves.instance.androidOpenLocationService((result){})
FlutterBlueElves.instance.androidApplyBluetoothPermission((result){})
具体的使用可以看我的example项目

@yh4922
Copy link
Author

yh4922 commented Dec 15, 2021

我用permission_handler申请了权限之后 还需要再 AndroidManifest.xml 中加上
感谢😄

@yh4922 yh4922 closed this as completed Dec 15, 2021
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

2 participants