aboutsummaryrefslogtreecommitdiff
path: root/ParrotZik.py
diff options
context:
space:
mode:
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