flutter_blue找不到HC-05蓝牙模块

问题描述

我正在将Flutter_blue用于Android应用。我已授予所有必需的权限,并在手机上启用了GPS。开始扫描时,我可以看到蓝牙设备的列表,但找不到HC-05蓝牙模块。但是,当我直接使用手机可以找到HC-05模块时。谁能帮我吗?

这是我的扫描代码

FlutterBlue flb = _bluetoothService.getInstance();
    flb
        .startScan(timeout: Duration(seconds: 20),scanMode: ScanMode.lowPower)
        .then((x) {
      List<ScanResult> r = x as List<ScanResult>;
      r.forEach((a) {
        print('<<<<<');
        print('${a.device.id.id}');
        print(a.RSSi);
      });
    });

解决方法

HC-05是Bluetooth Classic模块,而不是Bluetooth Low Energy(BLE)模块。这就是为什么您可以通过手机操作系统中的常规Bluetooth Classic搜索而不是使用BLE库flutter_blue来找到它的原因。

您必须使用BLE模块或其他flutter_bluetooth_serial之类的flutter库。