adafruit / Adafruit_CircuitPython_BLE

Bluetooth Low Energy (BLE) library for CircuitPython
MIT License
127 stars 58 forks source link

start_scan() advertisement_types needs to default to (Advertisement,) #76

Closed dhalbert closed 4 years ago

dhalbert commented 4 years ago

Fixes #75.

72 caused a regression in code that called start_scan() with no advertising_types.

ble_simpletest.py stopped working, for example.

caternuson commented 4 years ago

Looks good. Tested using two CLUEs and these simple test programs:

ADVERTISER:

from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

ble = BLERadio()
uart_service = UARTService()
advertisement = ProvideServicesAdvertisement(uart_service)
ble._adapter.name = "CLUE_FOO"

ble.start_advertising(advertisement)

while True:
    pass

SCANNER:

from adafruit_ble import BLERadio

ble = BLERadio()
print("scanning")

for advertisement in ble.start_scan():
    print(advertisement.complete_name)

print("scan done")

Previously, the scanner returned nothing. Now it finds and returns the name specified in the advertiser. The None returns are expected for this simple scanner that is not doing any filtering on return type.

Adafruit CircuitPython 5.1.0 on 2020-04-02; Adafruit CLUE nRF52840 Express with nRF52840
>>> import scan
scanning
None
CLUE_FOO
None
CLUE_FOO
None
CLUE_FOO

Also fixes this: https://forums.adafruit.com/viewtopic.php?f=50&t=164081