BLE在reactive_ble中没有读取特性



我正在使用flutter_reactive_ble包与ble设备通信。一切都很好,直到我试图读取给我以下错误的特征:

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'}")

这是我的代码块,包含函数:

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 $idn";
_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;
}

我已经尝试寻找其他的uuid特征,看看问题是否与uuid有关,但没有运气。我一直在用无线射频连接来检查一些参数。我在那里找到的uid是我目前使用的。我有北欧UART服务作为主要服务,我有以下服务:

  • 北欧UART服务'6E400001-B5A3-F393-E0A9-E50E24DCCA9E'
    • Rx特性'6E400002-B5A3-F393-E0A9-E50E24DCCA9E'-'写入,写入无响应'
    • Tx特性'6E400003-B5A3-F393-E0A9-E50E24DCCA9E'——"通知">

我如何解决这个问题并成功读取我需要的特性?

我想你看错了文档。Rx特性是您所连接设备的Rx特性。您只允许write到此特性,它将数据发送到连接的设备。数据从连接的设备发送到您的应用程序是通过Tx特性

Notify传递的。

最新更新