From 13312a1603ddec4bce301b49a1e18668b34147ea Mon Sep 17 00:00:00 2001 From: uvok Date: Sat, 2 Aug 2025 11:47:16 +0200 Subject: fbp: Don't discover after connect, discon --- .../flutter_blue_plus_device_connection.dart | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/model/connection/flutter_blue_plus_device_connection.dart b/lib/model/connection/flutter_blue_plus_device_connection.dart index 9cc73d1..abfc061 100644 --- a/lib/model/connection/flutter_blue_plus_device_connection.dart +++ b/lib/model/connection/flutter_blue_plus_device_connection.dart @@ -46,31 +46,33 @@ class FlutterBluePlusDeviceConnection implements DeviceConnection { // connect timeout doesn't work under Linux await dev.connect().timeout(Duration(seconds: 2)); // // ???? WTF ???? - List svcs = await dev.discoverServices(); - dev.onServicesReset.listen((_) async { - logger.i("Services Reset"); - // try { - // List svcs = dev.servicesList; - // findCharac(svcs); - // } catch (e) { - // logger.e(e); - // } - }); - - logger.i("services discovered"); - - findCharac(svcs); - - _status.value = ConnectionStatus.connected; - - await Future.delayed(Duration(seconds: 5)); - logger.i("Try re-discover"); - svcs = await dev.discoverServices(); + // List svcs = await dev.discoverServices(); + // dev.onServicesReset.listen((_) async { + // logger.i("Services Reset"); + // // try { + // // List svcs = dev.servicesList; + // // findCharac(svcs); + // // } catch (e) { + // // logger.e(e); + // // } + // }); + + // logger.i("services discovered"); + + // findCharac(svcs); + + // _status.value = ConnectionStatus.connected; + + // await Future.delayed(Duration(seconds: 5)); + // logger.i("Try re-discover"); + // svcs = await dev.discoverServices(); } @override Future disconnect() async { + final dev = device.scanResult.device; subs.cancel().ignore(); + await dev.disconnect(); _status.value = ConnectionStatus.disconnected; } -- cgit v1.2.3