Last active
February 2, 2020 22:01
-
-
Save tomiti/33585efd844767accd6d75843a807425 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 bluepy import btle | |
from bluepy.btle import Scanner, DefaultDelegate | |
class ble_delegate(DefaultDelegate): | |
def __init__(self, params): | |
btle.DefaultDelegate.__init__(self) | |
# ... initialise here | |
def handleDiscovery(self, dev, isNewDev, isNewData): | |
if isNewDev: | |
print('Discovered device %s' % dev.addr) | |
elif isNewData: | |
print('Received new data from %s' % dev.addr) | |
def handleNotification(self, cHandle, data): | |
# 9-axis IMU sample, 16-bit sample each | |
if (len(data) == 18): | |
samples_tuple = struct.unpack('<hhhhhhhhh', data) | |
print(samples_tuple) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment