Home > Enterprise >  BLE not reading characteristic in reactive_ble
BLE not reading characteristic in reactive_ble

Time:07-16

I'm using the flutter_reactive_ble package to communicate with a ble device. 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. I've been using nRF Connect to check on some parameters. The uuids I found there are the ones I'm using currently. I have Nordic UART Service as a primary service and I have the following:

  • Nordic UART Service '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'
    • Rx Characteristic '6E400002-B5A3-F393-E0A9-E50E24DCCA9E' -'WRITE, WRITE NO RESPONSE'
    • Tx Characteristic '6E400003-B5A3-F393-E0A9-E50E24DCCA9E' -'NOTIFY'

How can I fix this and sucessfully read the characteristics I need?

CodePudding user response:

I think you misread the documentation. The Rx Characteristic is the Rx Characteristic of the device you are connected to. You are only allowed to write to this characteristic, which sends data to the connected device. Data send from the connected device to your application is delivered via the Notify of the Tx Characteristic

  • Related