This renames Smart* to BLE* and removes the smart recognition. It is replaced by knowing the type of what we're interested at use time only. Only printing Service lists is now dumber. Interal variables to _bleio classes are now public as bleio_* instead so that other classes in the library can access them and its clearer what they are.
27 lines
985 B
Python
27 lines
985 B
Python
# This example scans for any BLE advertisements and prints one advertisement and one scan response
|
|
# from every device found. This scan is more detailed than the simple test because it includes
|
|
# specialty advertising types.
|
|
|
|
from adafruit_ble import BLERadio
|
|
|
|
from adafruit_ble.advertising import Advertisement
|
|
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
|
|
|
|
ble = BLERadio()
|
|
print("scanning")
|
|
found = set()
|
|
scan_responses = set()
|
|
# By providing Advertisement as well we include everything, not just specific advertisements.
|
|
for advertisement in ble.start_scan(ProvideServicesAdvertisement, Advertisement):
|
|
addr = advertisement.address
|
|
if advertisement.scan_response and addr not in scan_responses:
|
|
scan_responses.add(addr)
|
|
elif not advertisement.scan_response and addr not in found:
|
|
found.add(addr)
|
|
else:
|
|
continue
|
|
print(addr, advertisement)
|
|
print("\t" + repr(advertisement))
|
|
print()
|
|
|
|
print("scan done")
|