Created
July 16, 2020 03:38
-
-
Save siddacious/793d79e888f2be1d2f533cbd406b3166 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from adafruit_ble import BLERadio | |
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement, Advertisement, to_hex | |
from adafruit_ble.services.nordic import UARTService | |
import time | |
from adafruit_ble import BLERadio | |
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement | |
from adafruit_ble.services.nordic import UARTService | |
ble = BLERadio() | |
while True: | |
while ble.connected: | |
for connection in ble.connections: | |
print(repr(connection)) | |
print("") | |
time.sleep(1) | |
print("disconnected, scanning") | |
for ad in ble.start_scan(ProvideServicesAdvertisement,Advertisement, timeout=4): | |
print("Found ad:", ad.complete_name, "RSSI:", ad.rssi) | |
print(repr(ad)) | |
if ad.complete_name == 'DROID': | |
ble.connect(ad) | |
break | |
ble.stop_scan() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment