From 7ef0b760248cf13bec5c6143b044ea4b3ba8669a Mon Sep 17 00:00:00 2001 From: Stricted Date: Wed, 7 Oct 2015 22:18:00 +0200 Subject: [PATCH] reenable changeLTEStatus support --- lib/trait/Connection.class.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/trait/Connection.class.php b/lib/trait/Connection.class.php index 4361d5d..07d0d9b 100644 --- a/lib/trait/Connection.class.php +++ b/lib/trait/Connection.class.php @@ -24,13 +24,12 @@ trait Connection { if ($data['status'] == 'ok') { return true; } - else { - return false; - } } else { throw new RouterException('unknown status'); } + + return false; } /** @@ -40,7 +39,11 @@ trait Connection { * @return boolean */ public function changeLTEStatus ($status) { - throw new Exception('unstable funtion'); + $this->checkLogin(); + + /* we have to wait 400ms before we can send the request (idk whats wrong with the router) */ + usleep(400); + $path = 'data/Modules.json'; if ($status == '0' || $status == '1' || $status == 'yes' || $status == 'no') { @@ -49,13 +52,17 @@ trait Connection { $fields = array('csrf_token' => $this->token, 'use_lte' => $status); $data = $this->sendEncryptedRequest($path, $fields, true); + $data = $this->getValues($data['body']); - // debug only - return $data; + if ($data['status'] == 'ok') { + return true; + } } else { throw new RouterException('unknown status'); } + + return false; } /** @@ -66,10 +73,16 @@ trait Connection { public function reconnectLte () { $this->checkLogin(); + /* we have to wait 400ms before we can send the request (idk whats wrong with the router) */ + usleep(400); + $path = 'data/modules.json'; $fields = array('csrf_token' => $this->token, 'lte_reconn' => '1'); $data = $this->sendEncryptedRequest($path, $fields, true); + if ($data['status'] == 'ok') { + return true; + } - return $data['body']; + return false; } } -- 2.20.1