10000 Fix ScanEntry prefix matching for any=False by dhalbert · Pull Request #3036 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Fix ScanEntry prefix matching for any=False #3036

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

Merged
merged 2 commits into from
Jun 16, 2020

Conversation

dhalbert
Copy link
Collaborator

Fixes #2973.

Tested with a heart rate monitor advertisement with this program:

from _bleio import adapter, Address, ScanEntry

def p(x):
    print(tuple(hex(b) for b in x))

# Reverse the two prefixes to test both orders.
prefixes = b"\x07" b"\x03\x0D\x18\x0A\x18\x25\x17"       b"\x03" b"\x19\x41\x03"
p(prefixes)
HRM_ADDR = Address(bytes(reversed(b"\xEC\x5D\x34\x85\x99\x11")), Address.RANDOM_STATIC)
# active=False: skip scan responses
for se in adapter.start_scan(active=False):
    #print(se.address, se.address.type, HRM_ADDR, HRM_ADDR.type)
    if se.address == HRM_ADDR:
        print("equal")
        p(se.advertisement_bytes)
        print("all", se.matches(prefixes, all=True))
        print("any", se.matches(prefixes, all=False))
        break

@dhalbert dhalbert requested a review from tannewt June 15, 2020 20:41
Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! Just need to remove debug comments.

@tannewt tannewt added this to the 5.x.x - Bug Fixes milestone Jun 15, 2020
@dhalbert dhalbert requested a review from tannewt June 15, 2020 22:11
@dhalbert
Copy link
Collaborator Author

Looks good! Thank you! Just need to remove debug comments.

Oops! So much for hurrying up before lunch :)

Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@tannewt tannewt merged commit 0e3cad0 into adafruit:main Jun 16, 2020
@dhalbert dhalbert deleted the prefix-match-all branch June 19, 2020 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_bleio.ScanEntry.matches() is too strict for "all=True" matches
2 participants
0