Skip to content

Commit 4465db2

Browse files
committed
Stop returning Advertisement objects accidentally
They would be returned if the scan prefix matched but no advertising_types matches function matched.
1 parent 0658d8d commit 4465db2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adafruit_ble/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ def start_scan(self, *advertisement_types, buffer_size=512, extended=False, time
222222
for possible_type in advertisement_types:
223223
if possible_type.matches(entry) and issubclass(possible_type, adv_type):
224224
adv_type = possible_type
225+
# Double check the adv_type is requested. We may return Advertisement accidentally
226+
# otherwise.
227+
if adv_type not in advertisement_types:
228+
continue
225229
advertisement = adv_type.from_entry(entry)
226230
if advertisement:
227231
yield advertisement

0 commit comments

Comments
 (0)