I am working on connecting the blend micro to a python script running on a raspberry pi.
As of now I am able to ‘connect’ them, but I am not able to send and receive data.
The Code for the micro is the HelloWorld Example. I just added this line
For the raspberry i use the bluepy modul: http://ianharvey.github.io/bluepy-doc/index.html#
Code for raspberry is:
def getCompleteLocalName(dev): data = dict([(desc, value) for (adtype, desc, value) in dev.getScanData()]) return data.get("Complete Local Name") class ScanDelegate(DefaultDelegate): def __init__(self): DefaultDelegate.__init__(self) def handleDiscovery(self, dev, isNewDev, isNewData): if isNewDev and getCompleteLocalName(dev) == "My BLE": print "DISCOVERED MY BLE" if isNewData and getCompleteLocalName(dev) == "My BLE": print "Received new data from", dev.addr class PeriDelegate(DefaultDelegate): def __init__(self): DefaultDelegate.__init__(self) print "init peri" def handleNotification(self, cHandle, data): print data scanner = Scanner().withDelegate(ScanDelegate()) devices = scanner.scan(5.0) if __name__ == "__main__": for dev in devices: if getCompleteLocalName(dev) == "My BLE": print "Creating Peripheral" peri = Peripheral(dev) peri.setDelegate(PeriDelegate()) while True: if peri.waitForNotifications(1.0): print "There is something" # handleNotification() was called continue print "waiting"
Output from the python program is:
Received new data from db:b6:4d:4e:d6:0b Creating Peripheral init peri waiting waiting [...]
And the output from my arduino serial monitor:
Evt Connected Evt Pipe Status
So it looks like that there is a connection, but no communication.
How can i see the data in my script?
Thanks in advance.