diff options
author | Dmitry Moiseev <m0sia@m0sia.ru> | 2014-01-11 09:04:21 -0800 |
---|---|---|
committer | Dmitry Moiseev <m0sia@m0sia.ru> | 2014-01-11 09:04:21 -0800 |
commit | 39eb2669b37ac6cae34e6d57b002c865619cd98c (patch) | |
tree | 86bf57a4c1fd2b750ceb1e90a2b7ada09cb327b9 | |
parent | 240d800485b583a9d45e1c4a80e2ca766cbf8431 (diff) | |
download | pyParrotZikTCP-39eb2669b37ac6cae34e6d57b002c865619cd98c.tar.xz pyParrotZikTCP-39eb2669b37ac6cae34e6d57b002c865619cd98c.zip |
Lightblue support on Mac Os X
-rw-r--r-- | ParrotZik.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/ParrotZik.py b/ParrotZik.py index 4510e27..5a26b52 100644 --- a/ParrotZik.py +++ b/ParrotZik.py @@ -16,31 +16,38 @@ class ParrotZik(object): if sys.platform == "darwin": - service_matches = lightblue.findservices( name = "RFCOMM", addr = addr ) + service_matches = lightblue.findservices( name = "Parrot RFcomm service", addr = addr ) else: service_matches = bluetooth.find_service( uuid = uuid, address = addr ) + if len(service_matches) == 0: print "Failed to find Parrot Zik RFCOMM service" self.sock ="" return - first_match = service_matches[0] - port = first_match["port"] - name = first_match["name"] - host = first_match["host"] + if sys.platform == "darwin": + first_match = service_matches[0] + port = first_match[1] + name = first_match[2] + host = first_match[0] + else: + first_match = service_matches[0] + port = first_match["port"] + name = first_match["name"] + host = first_match["host"] print "Connecting to \"%s\" on %s" % (name, host) if sys.platform == "darwin": - self.sock=lightblue.lightblueSocket( lightblue.RFCOMM ) + self.sock=lightblue.socket() else: self.sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) self.sock.connect((host, port)) self.sock.send('\x00\x03\x00') - data = self.sock.recv(3) + data = self.sock.recv(1024) self.BatteryLevel = 100 self.BatteryCharging = False |