Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reset scan filters when stopScan is called [Fixes #350]#351

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
andrewchilds wants to merge1 commit intoarduino-libraries:master
base:master
Choose a base branch
Loading
fromandrewchilds:stopscan-bugfix

Conversation

@andrewchilds
Copy link

This PR addresses a bug outlined in#350, where callingstopScan does not reset the filters set byscanByName etc, so a call toscan after will not work as expected.

Here's a barebones sketch that demonstrates the bug:

#include<ArduinoBLE.h>#defineSERVICE_UUID"MY-SERVICE-UUID"unsignedlong scanStart;bool fallbackToFullScan =false;voidsetup() {  Serial.begin(9600);delay(1000);// Wait for serialif (!BLE.begin()) {    Serial.println("Starting BLE failed!");while (1);  }  Serial.println("Scanning by Service UUID...");  BLE.scanForUuid(SERVICE_UUID);  scanStart =millis();}voidnotWorkingScan() {  BLE.stopScan();delay(1000);// This scan will not work - it will continue to behave like BLE.scanForUuid(SERVICE_UUID)  BLE.scan();}voidworkingScan() {// This will reset _scanNameFilter, _scanUuidFilter, and _scanAddressFilter to ""  BLE.scanForUuid("");  BLE.stopScan();delay(1000);// This scan will now work  BLE.scan();}voidloop() {  BLEDevice peripheral = BLE.available();if (peripheral) {    Serial.println("Peripheral found!");    BLE.stopScan();  }// Wait 5 seconds to connect, then fall back to a regular scan.if (!fallbackToFullScan &&millis() - scanStart >5000) {    scanStart =millis();    Serial.println("Falling back to full scan...");    fallbackToFullScan =true;// notWorkingScan();workingScan();  }}

@CLAassistant
Copy link

CLAassistant commentedFeb 5, 2024
edited
Loading

CLA assistant check
All committers have signed the CLA.

@per1234per1234 added type: imperfectionPerceived defect in any part of project topic: codeRelated to content of the project itself labelsFeb 5, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

BLE.scan will not work after a BLE.scanFor[Uuid|Name|Address], even after a BLE.stopScan

3 participants

@andrewchilds@CLAassistant@per1234

[8]ページ先頭

©2009-2025 Movatter.jp