【问题标题】:Flutter Blue Read characteristic UUIDFlutter Blue 读取特征 UUID
【发布时间】:2018-08-20 14:17:44
【问题描述】:

我正在使用 flutter blue 连接 adafruit 羽毛板并读入/写入一些值。我将如何设置我希望从中读取的新特征?我已按照示例进行操作,但在阅读我的 arduino 代码中生成的双精度值时遇到了困难。

 //Read Uuid

 BluetoothCharacteristic readCharacter = new
 BluetoothCharacteristic(uuid: null, serviceUuid: 6e400001-b5a3-f393-e0a9- 
 e50e24dcca9e, descriptors: null,
  properties: null);
//Write UUID

我不确定我想要的特定蓝牙特性的声明需要什么参数。文档指示我不确定如何格式化的 uuid?

此外,如果有任何其他简单项目的示例读取和写入值并建立用户界面,那将很高兴查看。

【问题讨论】:

  • 更新:解决了这个问题。 (c.uuid == new Guid('blah blah..') 是声明 uuid 的正确方法。必须区分服务 uuid 和特征 uuid。使用特征 uuid 并保存为变量。
  • 从那里将 int/byte 数组解析为我希望获得的双精度值。可以在此处找到这些应用程序的有用示例项目:github.com/Sensirion/smart-gadget-flutter

标签: bluetooth flutter flutter-dependencies


【解决方案1】:

您可以通过调用 BluetoothCharacteristic.uuid 从 BluetoothCharacteristic 获取 UUID。

要过滤特定的 UUID,您可以在 for 循环中设置一个条件,从 BluetoothService 读取所有特征。

List<BluetoothCharacteristic> characteristics = service.characteristics; 

for(BluetoothCharacteristic c in characteristics) {
  if(c.uuid == Guid('YOUR_UUID')) debugPrint('${c.uuid} found!');
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-30
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    • 2016-07-26
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    相关资源
    最近更新 更多