Bluetooth PlatformException试图在Flatter blue上读取特征

Bluetooth PlatformException试图在Flatter blue上读取特征,bluetooth,bluetooth-lowenergy,flutter,Bluetooth,Bluetooth Lowenergy,Flutter,我试图从带有插件的设备上读取所有服务的所有特征,但它向我抛出了以下错误: [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter (24425): PlatformException(read_characteristic_error, unknown reason, may occur if readCharacteristic was called before last read fi

我试图从带有插件的设备上读取所有服务的所有特征,但它向我抛出了以下错误:

[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (24425): PlatformException(read_characteristic_error, unknown reason, may occur if readCharacteristic was called before last read finished., null)
E/flutter (24425): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:547:7)
E/flutter (24425): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
E/flutter (24425): <asynchronous suspension>
E/flutter (24425): #2      BluetoothDevice.readCharacteristic (file:///C:/Users/Downloads/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_blue-0.3.3/lib/src/bluetooth_device.dart:56:10)
E/flutter (24425): <asynchronous suspension>
E/flutter (24425): #3      _ListTabState._connectToDevice._readCarachteristics (file:///C:/Users/AndroidStudioProjects/my_app/lib/tab_base.dart:125:49)
E/flutter (24425): <asynchronous suspension>
E/flutter (24425): #4      _ListTabState._connectToDevice._showServices (file:///C:/Users/AndroidStudioProjects/my_app/lib/tab_base.dart:157:27)
E/flutter (24425): <asynchronous suspension>
E/flutter (24425): #5      _ListTabState._connectToDevice._connect.<anonymous closure> (file:///C:/Users/AndroidStudioProjects/my_app/lib/tab_base.dart:197:24)
E/flutter (24425): #6      _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter (24425): #7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
E/flutter (24425): #8      _DelayedData.perform (dart:async/stream_impl.dart:578:14)
E/flutter (24425): #9      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:694:11)
E/flutter (24425): #10     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:654:7)
E/flutter (24425): #11     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (24425): #12     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[错误:topaz/lib/tonic/logging/dart\u ERROR.cc(16)]未处理的异常:
E/颤振(24425):平台异常(如果在最后一次读取完成之前调用了readCharacteristic,则可能会发生readCharacteristic错误,原因未知,null)
E/flatter(24425):#0 StandardMethodCodec.decodeEnvelope(包:flatter/src/services/message_编解码器。dart:547:7)
E/flatter(24425):#1 MethodChannel.invokeMethod(包:flatter/src/services/platform_channel.dart:279:18)
E/颤振(24425):但无法解决它。谢谢你的支持

已更新


似乎信标发送的特定特征是以一种特殊的方式组成的,这打破了readCharacteristic方法。它们应该包含两个未被readDescriptor函数读取的uuid子类型。

有三个服务,其中第三个应用于读取和写入特征。前两个是通用的,第三个是自定义服务,它将使用这些服务。试试这个:

_scanResult.device.discoverServices().then((services){
        services[2].characteristics[0].read();
    });
_scanResult.device.discoverServices().then((services){
        services[2].characteristics[0].read();
    });