aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Moiseev <m0sia@m0sia.ru>2013-11-01 15:38:37 +0600
committerDmitry Moiseev <m0sia@m0sia.ru>2013-11-01 15:38:37 +0600
commitf5420ce3be919e25fc29cfc86f828d18725ec527 (patch)
treed85aa97f7ecc4b3ccb1db9e04c5cef0af535bb27
parentbe7c0805ee0ada7566caf5dc488b89fdcaeea234 (diff)
downloadpyParrotZikTCP-f5420ce3be919e25fc29cfc86f828d18725ec527.tar.xz
pyParrotZikTCP-f5420ce3be919e25fc29cfc86f828d18725ec527.zip
added volume change notification handling
Diffstat (limited to '')
-rw-r--r--ParrotZik.py17
1 files 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