aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Siarkowicz <mareksiarkowicz@gmail.com>2015-06-13 03:25:22 +0200
committerMarek Siarkowicz <mareksiarkowicz@gmail.com>2015-06-13 03:25:22 +0200
commit2d12b23595a7c893231d5238f406054d040aac01 (patch)
tree88de96e64226346deefa5852e1442ccf90d9ec93
parent52fb4f7f5561c38631e279a403cd55d8a6632955 (diff)
downloadpyParrotZikTCP-2d12b23595a7c893231d5238f406054d040aac01.tar.xz
pyParrotZikTCP-2d12b23595a7c893231d5238f406054d040aac01.zip
Fix flight mode.
-rw-r--r--ParrotProtocol.py4
-rw-r--r--ParrotZik.py21
2 files changed, 18 insertions, 7 deletions
diff --git a/ParrotProtocol.py b/ParrotProtocol.py
index a844820..a4e1677 100644
--- a/ParrotProtocol.py
+++ b/ParrotProtocol.py
@@ -13,8 +13,8 @@ def generateHeader(requestString):
def getRequest(resource):
- return generateRequest("GET " + resource + '/get')
+ return generateRequest("GET " + resource)
def setRequest(resource, args):
- return generateRequest("SET " + resource + '/set' + "?arg=" + args)
+ return generateRequest("SET " + resource + "?arg=" + args)
diff --git a/ParrotZik.py b/ParrotZik.py
index 80dc591..c6cfd92 100644
--- a/ParrotZik.py
+++ b/ParrotZik.py
@@ -67,11 +67,19 @@ class ParrotZikApi(object):
return data.answer.software['sip6']
def get(self, resource):
- message = ParrotProtocol.getRequest(resource)
+ message = ParrotProtocol.getRequest(resource + '/get')
+ return self.send_message(message)
+
+ def toggle_on(self, resource):
+ message = ParrotProtocol.getRequest(resource + '/enable')
+ return self.send_message(message)
+
+ def toggle_off(self, resource):
+ message = ParrotProtocol.getRequest(resource + '/disable')
return self.send_message(message)
def set(self, resource, arg):
- message = ParrotProtocol.setRequest(resource, str(arg).lower())
+ message = ParrotProtocol.setRequest(resource + '/set', str(arg).lower())
return self.send_message(message)
def send_message(self, message):
@@ -81,9 +89,9 @@ class ParrotZikApi(object):
self.sock = ""
return
if sys.platform == "darwin":
- data = self.sock.recv(30)
+ self.sock.recv(30)
else:
- data = self.sock.recv(7)
+ self.sock.recv(7)
data = self.sock.recv(1024)
data = BeautifulSoup(data)
return data
@@ -216,7 +224,10 @@ class ParrotZikVersion2(ParrotZikBase):
@flight_mode.setter
def flight_mode(self, arg):
- self.api.set('/api/flight_mode', arg)
+ if arg:
+ self.api.toggle_on('/api/flight_mode')
+ else:
+ self.api.toggle_off('/api/flight_mode')
@property
def sound_effect(self):