From f5420ce3be919e25fc29cfc86f828d18725ec527 Mon Sep 17 00:00:00 2001 From: Dmitry Moiseev Date: Fri, 1 Nov 2013 15:38:37 +0600 Subject: added volume change notification handling --- ParrotZik.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ParrotZik.py b/ParrotZik.py index 75680cc..2746259 100644 --- a/ParrotZik.py +++ b/ParrotZik.py @@ -27,6 +27,8 @@ class ParrotZik(object): self.sock.send('\x00\x03\x00') data = self.sock.recv(3) + + self.BatteryLevel = 100 print "Connected" def getBatteryState(self): @@ -34,11 +36,18 @@ class ParrotZik(object): return data.answer.system.battery["state"] def getBatteryLevel(self): - data = self.sendGetMessage("/api/system/battery/get") + data = self.sendGetMessage("/api/system/battery/get") + try: + self.BatteryLevel = data.answer.system.battery["level"] + except: + pass + try: - return data.answer.system.battery["level"] + print "notification received" + data.notify["path"] except: - return "0" + pass + + return self.BatteryLevel def getVersion(self): data = self.sendGetMessage("/api/software/version/get") @@ -80,7 +89,7 @@ class ParrotZik(object): self.sock.send(str(message)) data = self.sock.recv(7) len = struct.unpack('B', data[1])[0] - data = self.sock.recv(len) + data = self.sock.recv(1024) data=BeautifulSoup(data) return data -- cgit v1.2.1