chipweinberger / flutter_blue_plus

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

[Help]: App not always seeing the advertisement of a device #782

Closed amasuke55 closed 9 months ago

amasuke55 commented 10 months ago

Requirements

Have you checked this problem on the example app?

No

FlutterBluePlus Version

Issue persists through a lot of versions

Flutter Version

3.10.5

What OS?

Android

OS Version

13

Bluetooth Module

Nordic nRF52805

What is your problem?

The App randomly refuses to list a device again when scanning for ble devices. Usually happens when the device was connected and disconnected before. (But not exclusively when that was done) Usually it works, until the device gets disconnected and then this behaviour can start.

A fix I found is going into the android Bluetooth settings and scanning there. Once the OSs scanning found the device, it will then show up in the App. Sometimes not even that is fixing it.

This does not produce exceptions and I do not know what could be causing this. The results are simply being shown with the same logic used in the example code. Listening to onScanResults and listing the ScanResultTile.

While the App is not showing the advertising device anymore, another mobilephone with the same app on it, can find it. So it does not seem to be an issue of the device not advertising correctly.

I already tried different AndroidScanModes. Only on LowPower mode it happens less frequently, but still happens.

Scanning is always started like this:

await FlutterBluePlus.startScan(timeout: const Duration(minutes: 3), removeIfGone: const Duration(seconds: 10), continuousUpdates: true, androidScanMode: AndroidScanMode.lowPower);

I tried different timeouts and AndroidScanModes

Logs

Unfortunately no exceptions or log entries from this issue.
chipweinberger commented 10 months ago

Does it happen without removeIfGone? does it happen if you remove both continuousUpdates & removeIfGone?

I'd suggest adding additional logs to the scanning code in Dart & Java side.

I won't be fixing this myself. so please open a PR if you want this fixed.

see README for debugging instructions.

also, I suggest you test with the example app.

amasuke55 commented 10 months ago

Hello, thanks for the reply, It does happen without continuousUpdates & removeIfGone too. I cloned the repo and am trying to figure out what's going on.

chipweinberger commented 10 months ago

does your device stop advertising after connected to?

chipweinberger commented 9 months ago

any updates?

chipweinberger commented 9 months ago

can't fix without more information.