无法使用 Flutter_bluetooth_serial 包连接到设备

问题描述

但是我收到那个错误

D/FlutterBluePlugin(3903):连接到 74:DF:BF:9B:46:2E (id: 2) I/BluetoothAdapter(3903):canceldiscovery I/BluetoothAdapter(3903): canceldiscovery = false D/BluetoothUtils(3903): isSocketAllowedBySecurityPolicy start : device null I/BluetoothSocket( 3903): connect() 用于设备 74DFBF 调用的 pid: 3903 W/BluetoothAdapter(3903): getBluetoothService() 调用时没有 BluetoothManagerCallback I/Flutter(3903): PlatformException(连接错误,读取失败,套接字可能关闭或 超时,读取 ret:-1,java.io.IOException:读取失败,套接字可能 关闭或超时,读取 ret: -1 I/Flutter ( 3903): at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:970) I/颤振(3903):在 android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:984) I/颤振(3903):在 android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:536) I/颤振(3903):在 io.github.edufolly.Flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:57) I/颤振(3903):在 io.github.edufolly.Flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:64) I/颤振(3903):在 io.github.edufolly.Flutterbluetoothserial.FlutterBluetoothSerialPlugin.lambda$onMethodCall$0$FlutterBluetoothSerialPlugin(FlutterBluetoothSerialPlugin.java:880) I/颤振(3903):在 io.github.edufolly.Flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$IghJwXXwUz_TFyaj49DgLpHhUY4.run(未知 来源:10) I/Flutter (3903):在 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) I/颤振(3903):在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoo

这是我的连接代码

Future<bool> connect(String address) async {
    BluetoothConnection _bluetoothConnection;
    try {
      _bluetoothConnection = await BluetoothConnection.toAddress(address);
      return _bluetoothConnection.isConnected ? true : false;
    } catch (e) {
      print(e);
    }
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...