Created
August 28, 2018 04:30
-
-
Save sowbug/ef5bb8886fbfa949cf47e492ddcb8b50 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import binascii | |
from bluepy import btle | |
from bluepy.btle import DefaultDelegate | |
class MyDelegate(btle.DefaultDelegate): | |
def __init__(self, params): | |
btle.DefaultDelegate.__init__(self) | |
def handleNotification(self, cHandle, data): | |
print "SOMETHING HAPPENED %s" % (binascii.hexlify(data)) | |
p = btle.Peripheral("f6:c3:37:01:ee:36", btle.ADDR_TYPE_RANDOM) | |
p.withDelegate(MyDelegate(None)) | |
buttonCharacteristic = p.getCharacteristics(uuid="99c31525-dc4f-41b1-bb04-4e4deb81fadd")[0] | |
setup_data = b"\x01\x00" | |
notify_handle = buttonCharacteristic.getHandle() + 1 | |
p.writeCharacteristic(notify_handle, setup_data, withResponse=True) | |
print "Connected!" | |
while True: | |
print "Waiting..." | |
if p.waitForNotifications(5.0): | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment