Skip to content

fbp-code: 6 | device is not connected #36

@bobosette

Description

@bobosette

Hi everybody.
I don't know if this is a bug, but I would like to know why when I connect my device (the device detect the connectio as per the application) when I try
characteristic.write(command);
or
await characteristic.setNotifyValue(true);
I get this error: ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: FlutterBluePlusException | writeCharacteristic | fbp-code: 6 | device is not connected.

Could someone help me?
Thank you

Flutter Windows
Channel Stable 3.32.2
flutter_blue_plus_windows

`Future onConnectPressed(BluetoothDevice dev) async {
try {
blueDevice = dev;

  await blueDevice.connect(); //connect

  if (GetPlatform.isWindows) {
    await blueDevice.connectionState
        .where((s) => s == BluetoothConnectionState.connected)
        .first;
  }

  services = await blueDevice.discoverServices(); //discover services

  await Future.delayed(const Duration(milliseconds: 500));

  subscribe(); //subscribe to characteristic

  connectionStateSubscription =
      blueDevice.connectionState.listen((state) async {
    connectionState = state;
    if (connectionState == BluetoothConnectionState.disconnected) {
      if (downloadChain == DownloadState.start ||
          downloadChain == DownloadState.startAll) {
        hideOverlay();
        showBluetoothErrorDialog(
            'Connection timeout\nAlphaDBSpat disconnected'.tr);
      }
    }

    update();
  });
} catch (e) {
  if (e is FlutterBluePlusException &&
      e.code == FbpErrorCode.connectionCanceled.index) {
    // ignore connections canceled by the user
  } else {
    debugPrint(e.toString());
  }
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions