Skip to content

Commit 560f0b2

Browse files
committed
clean up matches()
1 parent f9f8b93 commit 560f0b2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

adafruit_ble/advertising/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,15 @@ def get_prefix_bytes(cls):
304304
return cls._prefix_bytes
305305

306306
@classmethod
307-
def matches(cls, entry, all_=True):
307+
def matches(cls, entry):
308+
"""Returns ``True`` if the given `_bleio.ScanEntry` advertisement fields
309+
matches all of the given prefixes in the `match_prefixes` tuple attribute.
310+
Subclasses may override this to match any instead of all.
311+
"""
312+
return cls.matches_prefixes(entry, all_=True)
313+
314+
@classmethod
315+
def matches_prefixes(cls, entry, *, all_):
308316
"""Returns ``True`` if the given `_bleio.ScanEntry` advertisement fields
309317
match any or all of the given prefixes in the `match_prefixes` tuple attribute.
310318
If `all_` is ``True``, all the prefixes must match. If ``all_`` is ``False``,

adafruit_ble/advertising/standard.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,11 @@ def __init__(self, *services):
184184
self.flags.le_only = True
185185

186186
@classmethod
187-
def matches(cls, entry, all_=False):
188-
return super().matches(entry, all_=all_)
187+
def matches(cls, entry):
188+
"""Only one kind of service list need be present in a ProvideServicesAdvertisement,
189+
so override the default behavior and match any prefix, not all.
190+
"""
191+
return cls.matches_prefixes(entry, all_=False)
189192

190193

191194
class SolicitServicesAdvertisement(Advertisement):

0 commit comments

Comments
 (0)