adafruit / Adafruit_CircuitPython_BLE

Bluetooth Low Energy (BLE) library for CircuitPython
MIT License
124 stars 57 forks source link

start_scan(): if no Advertisements are given, nothing is returned. #75

Closed dhalbert closed 4 years ago

dhalbert commented 4 years ago

This recent changed to the code in start_scan():

            # Double check the adv_type is requested. We may return Advertisement accidentally
            # otherwise.
            if adv_type not in advertisement_types:
                continue

means that if no advertisement_types are given, no advertisements at all will be returned by start_scan(), so it appears as if nothing is advertising. Previously, all received advertisements would be returned as Advertisement objects.

@tannewt I thought I understand your change in #72, but now I realize I didn't.

I think advertisement_types should be set to (Advertisement,) if it comes in as empty.

tannewt commented 4 years ago

Yup, I believe we need a default for advertisement_types when it is empty. The bug I fixed was that when a type is given, Advertisements were returned if a scan matched the first prefix but not the class's match().