简体   繁体   English

BLE未读取reactive_ble中的特征

[英]BLE not reading characteristic in reactive_ble

I'm using the flutter_reactive_ble package to communicate with a ble device.我正在使用 flutter_reactive_ble 包与 ble 设备进行通信。 All is good until I try to read the characteristic which gives me the following error:一切都很好,直到我尝试阅读给我以下错误的特征:

E/flutter (28251): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Exception: GenericFailure<CharacteristicValueUpdateError>(code: CharacteristicValueUpdateError.unknown, message: "GATT exception from MAC address EE:2F:27:FE:D2:44, with type BleGattOperation{description='CHARACTERISTIC_READ'}")

This is my code block that contains the function:这是我的包含函数的代码块:

Uuid _UART_UUID = Uuid.parse("6E400001-B5A3-F393-E0A9-E50E24DCCA9E");
Uuid _UART_RX = Uuid.parse("6E400002-B5A3-F393-E0A9-E50E24DCCA9E");
Uuid _UART_TX = Uuid.parse("6E400003-B5A3-F393-E0A9-E50E24DCCA9E");  

case DeviceConnectionState.connected:
          {
            _connected = true;
            _logTexts = "${_logTexts}Connected to $id\n";
            _numberOfMessagesReceived = 0;
            _receivedData = [];

            //READ
            final _rxCharacteristic = QualifiedCharacteristic(
              serviceId: _UART_UUID,
              characteristicId: _UART_RX,
              deviceId: event.deviceId,
            );
            try {
              final _charResponse =
                  flutterReactiveBle.readCharacteristic(_rxCharacteristic);
              print(_charResponse);
            } catch (e) {
              print("COULDN'T READ CHARACTERISTIC $e");
            }

            break;
          }

I already tried finding other characteristic uuids to see if the problem was about the uuid, but no luck.我已经尝试寻找其他特征 uuid 以查看问题是否与 uuid 有关,但没有运气。 I've been using nRF Connect to check on some parameters.我一直在使用 nRF Connect 来检查一些参数。 The uuids I found there are the ones I'm using currently.我在那里找到的 uuid 是我目前正在使用的。 I have Nordic UART Service as a primary service and I have the following:我有北欧 UART 服务作为主要服务,我有以下内容:

  • Nordic UART Service '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'北欧 UART 服务 '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'
    • Rx Characteristic '6E400002-B5A3-F393-E0A9-E50E24DCCA9E' -'WRITE, WRITE NO RESPONSE' Rx 特性“6E400002-B5A3-F393-E0A9-E50E24DCCA9E”-“写,写无响应”
    • Tx Characteristic '6E400003-B5A3-F393-E0A9-E50E24DCCA9E' -'NOTIFY' Tx 特性“6E400003-B5A3-F393-E0A9-E50E24DCCA9E”-“通知”

How can I fix this and sucessfully read the characteristics I need?我该如何解决这个问题并成功读取我需要的特征?

I think you misread the documentation.我认为您误读了文档。 The Rx Characteristic is the Rx Characteristic of the device you are connected to. Rx 特性是您连接到的设备的Rx 特性 You are only allowed to write to this characteristic, which sends data to the connected device.您只能write此特征,它将数据发送到连接的设备。 Data send from the connected device to your application is delivered via the Notify of the Tx Characteristic从连接的设备发送到您的应用程序的数据通过Tx 特性Notify传递

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM