From 0d692102cd94f70e78cf036cb9f64c485ea8b6a5 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Fri, 12 Jun 2015 15:15:44 +0200 Subject: Add Zik 2.0 compatibility. --- BluetoothPairedDevices.py | 3 ++- ParrotZik.py | 19 +++++++++++++++---- ParrotZikTray | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/BluetoothPairedDevices.py b/BluetoothPairedDevices.py index 4190159..aa5b056 100644 --- a/BluetoothPairedDevices.py +++ b/BluetoothPairedDevices.py @@ -9,7 +9,8 @@ elif sys.platform == "win32": def ParrotZikMac(): - p = re.compile('90:03:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}') + p = re.compile('90:03:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}|' + 'A0:14:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}') if sys.platform == "linux2": out = os.popen("bluez-test-device list").read() res = p.findall(out) diff --git a/ParrotZik.py b/ParrotZik.py index 65c3417..551d19a 100644 --- a/ParrotZik.py +++ b/ParrotZik.py @@ -9,13 +9,18 @@ from BeautifulSoup import BeautifulSoup class ParrotZik(object): def __init__(self, addr=None): - uuid = "0ef0f502-f0ee-46c9-986c-54ed027807fb" + uuids = ["0ef0f502-f0ee-46c9-986c-54ed027807fb", + "8B6814D3-6CE7-4498-9700-9312C1711F63"] if sys.platform == "darwin": service_matches = lightblue.findservices( name="Parrot RFcomm service", addr=addr) else: - service_matches = bluetooth.find_service(uuid=uuid, address=addr) + for uuid in uuids: + service_matches = bluetooth.find_service(uuid=uuid, + address=addr) + if service_matches: + break if len(service_matches) == 0: print "Failed to find Parrot Zik RFCOMM service" @@ -77,7 +82,10 @@ class ParrotZik(object): @property def version(self): data = self.get("/api/software/version/get") - return data.answer.software["version"] + try: + return data.answer.software["version"] + except KeyError: + return data.answer.software['sip6'] @property def friendly_name(self): @@ -110,7 +118,10 @@ class ParrotZik(object): @property def lou_reed_mode(self): data = self.get("/api/audio/specific_mode/enabled/get") - return data.answer.audio.specific_mode["enabled"] + try: + return data.answer.audio.specific_mode["enabled"] + except TypeError: + pass @lou_reed_mode.setter def lou_reed_mode(self, arg): diff --git a/ParrotZikTray b/ParrotZikTray index 193f8d1..1f934ea 100755 --- a/ParrotZikTray +++ b/ParrotZikTray @@ -107,9 +107,9 @@ class ParrotZikIndicator(SysIndicator): def toggleANC(self, widget): if self.connected: if self.check.get_active(): - self.parrot.setNoiseCancel("true") + self.parrot.noise_cancel = "true" else: - self.parrot.setNoiseCancel("false") + self.parrot.noise_cancel = "false" def toggleAuto(self, widget): if self.connected: -- cgit v1.2.1