I'm able to traverse the services and characteristics of my BLE device in bluepy, but I'm unable to get asynchronous indications to print. I've looked at the suggestions in this question, but I can't get it working.
It does work when using gattool:
$ sudo gatttool -b "DF:01:93:A9:86:FF" -t random --char-write-req --handle=0x002c --value=0200 --listen
Characteristic value was written successfully
Indication handle = 0x002b value: 00 8a 00
Indication handle = 0x002b value: 00 8a 00
Indication handle = 0x002b value: 30 30 2d
But I can't get bluepy to do the same:
from bluepy.btle import Scanner, DefaultDelegate, Peripheral, ADDR_TYPE_RANDOM
class ReadCharacteristicDelegate(DefaultDelegate):
def __init__(self):
DefaultDelegate.__init__(self)
def handleNotification(self, cHandle, data):
print " got data: 0x%x" % data
periph = Peripheral('df:01:93:a9:86:ff', addrType=ADDR_TYPE_RANDOM)
periph.setDelegate(ReadCharacteristicDelegate())
periph.writeCharacteristic(0x002c, "\0x02\0x00")
print "Enabled indications"
while True:
if periph.waitForNotifications(3.0):
# handleNotification() was called
continue
print("Waiting")
It runs, but no indications ever print out:
$ sudo python simple.py
Enabled indications
Waiting
Waiting