chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
726 stars 442 forks source link

[Help]: IOS, The device is not connecting on autoconnect in the background #994

Closed Maqcel closed 4 days ago

Maqcel commented 6 days ago

Requirements

Have you checked this problem on the example app?

No

FlutterBluePlus Version

1.32.12

Flutter Version

3.22.2

What OS?

iOS

OS Version

17.6 (21G5066d)

Bluetooth Module

Own product can't discuss, All I can share: Bluetooth Low Energy device which uses GATT protocols along Bluetooth Advertising packets to transmit temperature readings measured by the device’s sensor.

What is your problem?

1 off all thank you for this package it's really cool how easy it was to pick up.

[FBP-iOS] didConnectPeripheral
[FBP-iOS] didDisconnectPeripheral:
[FBP-iOS]  error: The specified device has disconnected from us.

This error cancels autoconnect altogether (in the background), and somehow when disconnecting I'm not getting the connection status change from my stream:

  Stream<NotConnected> _listenDisconnected(BluetoothDevice device) =>
      device.connectionState
          .where((state) => state != BluetoothConnectionState.connected)
          .skip(1)
          .map((event) => NotConnected());

I tried to find the place in the library responsible for the error but failed to do so. I'm currently unable to reproduce this error in debug mode, but error sometimes persist (The notification about the NotConnected is not send only in case this error happening) I'm happy to answer more questions but currently I'm unable to reproduce

Logs

By my surprise, I can't replicate same error today when I opened the app to give full logs. But the issue persist in the version on my PM's phone.
chipweinberger commented 6 days ago

duplicate: https://github.com/chipweinberger/flutter_blue_plus/issues/846

chipweinberger commented 6 days ago

"The specified device has disconnected from us."

this is an error string from iOS, not FBP

and it sounds like your peripheral is requesting the disconnection.

Maqcel commented 6 days ago

Thank you for the response, haven't seen 846 will proceed with things from there!

I'll close it when I'll get it running tomorrow

Maqcel commented 4 days ago

Ahh Yes I forgot to do so, the upgrade from v13 helped! Thanks