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/33585efd844767accd6d75843a807425 to your computer and use it in GitHub Desktop.
Save tomiti/33585efd844767accd6d75843a807425 to your computer and use it in GitHub Desktop.
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