diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-03-23 02:08:53 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-03-23 02:08:53 +0300 |
commit | 71a26b49d933eb4f9c59e8d7e18c4fcd2d149d34 (patch) | |
tree | 7dceaf531b0ef1d62d8893caf00f1dabdac8cdc1 | |
parent | 2561239de30a3b9cfd6c88bab2056336a03fed4e (diff) |
upd
-rw-r--r-- | e3372.py | 23 | ||||
-rw-r--r-- | main.py | 18 |
2 files changed, 28 insertions, 13 deletions
@@ -28,13 +28,12 @@ class WebAPI: self.headers['__RequestVerificationToken'] = token self.headers['Content-Type'] = 'text/xml' - # def device_information(self): - # response = self.request('device/information') - # print(response) - # - # def device_signal(self): - # response = self.request('device/signal') - # print(response) + def device_information(self): + return self.request('device/information') + + def device_signal(self): + return self.request('device/signal') + def get_sms(self, count=10, page=1): request = build_request({ @@ -63,6 +62,16 @@ class WebAPI: def send_sms(self): pass + def dataswitch(self, on=True): + return self.request('dialup/mobile-dataswitch', data=build_request({ + 'dataswitch': 1 if on else 0 + })) + + def reboot(self): + return self.request('device/control', data=build_request({ + 'Control': 1 + })) + def request(self, endpoint: str, data=None): url = f'http://{self.ip}/api/{endpoint}' r = requests.get(url, headers=self.headers) if data is None else requests.post(url, data=data, headers=self.headers) @@ -13,13 +13,19 @@ def main(): client = WebAPI(args.ip) client.auth() - messages = client.get_sms() + info = client.device_information() + signal = client.device_signal() - for m in messages: - print(f"phone: {m.phone}") - print(f"date: {m.date} ({m.timestamp()})") - print(f"content: {m.content}") - print('-----') + print(info) + print(signal) + + # messages = client.get_sms() + # + # for m in messages: + # print(f"phone: {m.phone}") + # print(f"date: {m.date} ({m.timestamp()})") + # print(f"content: {m.content}") + # print('-----') if __name__ == '__main__': |