Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save siddacious/793d79e888f2be1d2f533cbd406b3166 to your computer and use it in GitHub Desktop.
Save siddacious/793d79e888f2be1d2f533cbd406b3166 to your computer and use it in GitHub Desktop.
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