Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startPeripheralScan not working as expected #601

Open
dajacmatt opened this issue Jun 21, 2021 · 0 comments
Open

startPeripheralScan not working as expected #601

dajacmatt opened this issue Jun 21, 2021 · 0 comments

Comments

@dajacmatt
Copy link

Hi,

I'm not totally sure if this is a ble_lib issue or a blemulator issue. I have two simulated peripherals, one with a service SERVICE_STATUS and one without. When I try to use bleManager.startPeripheralScan(uuids: [SERVICE_STATUS]) it returns both peripherals rather than just one. However, if I manually check each scan result's advertisementData then I get the desired results. I'm not super familiar with Dart/Flutter so there could just be some other dumb mistake in the relevant code:

Stream<ScanResult> timeoutScan( {int sec = 5}) {
    Future.delayed(Duration(seconds:sec), () {
      print("++++++ delayed scan stopping");
      bleManager.stopPeripheralScan();
    } );

    return bleManager.startPeripheralScan(uuids: [SERVICE_STATUS]); //this parameter makes no difference to the results
  }

...

Future<void> updateScan({timeout = 5}) async {
  Peripheral p;
  foundDevices.clear();

  if (!scanInProgress)
  {
    scanInProgress = true;
    await timeoutScan(sec: timeout).listen((scanResult) async {
      p = scanResult.peripheral;
      if (!foundDevices.contains(p) && !connectedDevices.contains(p) && scanResult.advertisementData.serviceUuids.contains(SERVICE_STATUS)) {
        foundDevices.addPeripheral(p);
      }

       ...

    }).asFuture();
    scanInProgress = false;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant