Created
February 2, 2020 22:03
-
-
Save tomiti/8f2b6134b549980551f65d7ac66dc63e 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
# 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