【问题标题】:Using Flutter to connect and write to Bluetooth Devices使用 Flutter 连接和写入蓝牙设备
【发布时间】:2019-08-02 11:19:33
【问题描述】:

我是 Flutter 的新手,正在努力完成这项工作。

我正在使用 Flutter Blue https://pub.dartlang.org/packages/flutter_blue

虽然可以连接,写的时候就是这个问题。

但是在写作时我收到了这条消息。不知道我做错了什么。

这是我的代码..

onPressed: () {
                  print("HEY write pressed");
                  var fff1 = new Guid("0000fff1-0000-1000-8000-00805f9b34fb");
                  var fffa = new Guid("0000fffa-0000-1000-8000-00805f9b34fb");
                  BluetoothCharacteristic characteristic = new BluetoothCharacteristic(uuid: fffa, serviceUuid: fff1, descriptors: null, properties: null);
                  _writeCharacteristic(characteristic);
               },

PlatformException(locateCharacteristic,服务无法在设备上定位,null)

我已尝试关注此帖子。 Flutter Blue Read characteristic UUID

在生产中我可能会将 UUID 保存为变量,但效果应该类似..

如果有人有任何指导或提示,将非常受欢迎。

【问题讨论】:

    标签: bluetooth flutter bluetooth-lowenergy


    【解决方案1】:

    您的代码是正确的,但您要连接的设备不包含此服务:var fff1 = new Guid("0000fff1-0000-1000-8000-00805f9b34fb");

    检查您要连接的设备中存在哪些服务。

    【讨论】:

    • 不,这不是原因。 flutter_blue 没有最好的异常处理。我对从设备获取的服务有同样的问题,这很奇怪,因为当我得到 id 为 f.e. 的字符时。 0x0 一秒钟后我的应用程序告诉设备上没有这个字符。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-08
    • 2020-01-27
    • 2016-03-13
    • 1970-01-01
    相关资源
    最近更新 更多