Android 颤振蓝牙扫描-未检测到树莓

Android 颤振蓝牙扫描-未检测到树莓,android,ios,flutter,bluetooth,raspberry-pi,Android,Ios,Flutter,Bluetooth,Raspberry Pi,大家好,谢谢大家阅读 因此,我有一个脚本,配置蓝牙到我的树莓皮4,使他发现 另一方面,我有一个flatter应用程序,可以检测蓝牙设备并在列表中显示它们 问题: 颤振应用程序没有检测到我的树莓,但检测到所有其他设备(蓝牙扬声器、耳机…)。 当我进入android手机的本机蓝牙扫描时,会检测到树莓,我可以与他连接 有人猜测为什么应用程序没有检测到树莓 多谢各位 这是raspberry脚本中的代码: ... # Coproc functions function sendCmd() { e

大家好,谢谢大家阅读

因此,我有一个脚本,配置蓝牙到我的树莓皮4,使他发现

另一方面,我有一个flatter应用程序,可以检测蓝牙设备并在列表中显示它们

问题: 颤振应用程序没有检测到我的树莓,但检测到所有其他设备(蓝牙扬声器、耳机…)。 当我进入android手机的本机蓝牙扫描时,会检测到树莓,我可以与他连接

有人猜测为什么应用程序没有检测到树莓

多谢各位

这是raspberry脚本中的代码:

...

# Coproc functions
function sendCmd() {
    echo "$1" >&"${bluetooth[1]}"
    read -r clean <&"${bluetooth[0]}"
    while [[ ! -z $clean ]]
    do
        read -r -t 1 clean <&"${bluetooth[0]}"
    done
}

# All commands for bluetoothctl
declare -a commands=("power on" "pairable on" 'discoverable on' 'agent on' 'default-agent')

# Start Coproc with bluetoothclt binding the process with 'bluetooth' name
echo -e "[CONFIGURATION] started"
coproc bluetooth {
    bluetoothctl;
}

for cmd in "${commands[@]}"
do
    echo -ne "\t'$cmd' "
    sendCmd "$cmd"
    echo 'done.'
done
echo -e "[CONFIGURATION] ended\n"

...
。。。
#Coproc函数
函数sendCmd(){
回声“$1”>&“${bluetooth[1]}”
读取-r清除0
?设备[索引]。名称
:“[没有名字]”),
字幕:
Text('Mac地址:'+devices[index].id.toString()),
);
},
),
),
]),
),
);
}
}

就像@DimaRostopira所说的,这是我使用的图书馆的一个问题


因此,我找到了一个新的与raspberry(基本上与RFCOMM)一起工作的颤振库:颤振\u蓝牙\u串行

您应该在github repo上填写这篇文章library@DimaRostopira非常感谢。你是对的,这是图书馆的问题(顺便说一句,不是唯一的问题)。我将在他们的GitHub上发布一个问题:)对于可能感兴趣的人,我刚刚找到了一个兼容的:flatter\u bluetooth\u serial
import 'package:flutter/material.dart';
import 'package:flutter_blue/flutter_blue.dart';

void main() {
  runApp(BluetoothApp());
}

class BluetoothApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'BluetoothApp',
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  Home() : super();

  HomeState createState() => HomeState();
}

class HomeState extends State<Home> {
  FlutterBlue flutterBlue = FlutterBlue.instance;
  List<BluetoothDevice> devices = List<BluetoothDevice>();

  @override
  void initState() {
    super.initState();

    _scanForDevices();
  }

  void _scanForDevices() async {
    print('Scanning...');
    flutterBlue.scan().listen((event) {
      if (!devices.contains(event.device)) {
        setState(() {
          devices.add(event.device);
        });
      }
    }).onError((err) {
      print('Error => ' + err.toString());
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Column(children: [
          Expanded(
            child: ListView.builder(
              itemCount: devices.length,
              itemBuilder: (context, index) {
                return ListTile(
                  title: Text(devices[index].name.length > 0
                      ? devices[index].name
                      : '[no name]'),
                  subtitle:
                      Text('Mac address : ' + devices[index].id.toString()),
                );
              },
            ),
          ),
        ]),
      ),
    );
  }
}