Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomiti/8f2b6134b549980551f65d7ac66dc63e to your computer and use it in GitHub Desktop.
Save tomiti/8f2b6134b549980551f65d7ac66dc63e to your computer and use it in GitHub Desktop.
# attempt connecting
try:
print('Connecting to ' + device_addr)
_ble_peripheral = btle.Peripheral(device_addr, addrType=btle.ADDR_TYPE_RANDOM)
_ble_peripheral.withDelegate(_ble_delegate)
# Setup to turn notifications on, e.g.
enable_notify(_ble_peripheral, IMU_SERVICE_UUID, IMU_SAMPLE_CHAR_UUID)
except Exception as e:
print(e)
# Main loop --------
while True:
if _ble_peripheral.waitForNotifications(0.007):
# handleNotification() was called in delegate
continue
# inform user main loop is running
sys.stdout.write('.')
sys.stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment