Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disconnect_lte #14

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eternalegypt/eternalegypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ def _config_call(self, key, value):
}
return self.websession.post(url, data=data)

@autologin
async def disconnect_lte(self):
"""Do an LTE disconnect."""
async with self._config_call('wwan.connect', 'Disconnect') as response:
_LOGGER.debug("Disconnected LTE with status %d", response.status)

@autologin
async def connect_lte(self):
"""Do an LTE reconnect."""
Expand Down
41 changes: 41 additions & 0 deletions examples/reconnect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

"""Example file for eternalegypt library."""

import sys
import asyncio
import aiohttp

import eternalegypt

import logging
logging.basicConfig(level=logging.DEBUG)

async def reconnect():
"""Example of disconnecting and reconnecting."""
jar = aiohttp.CookieJar(unsafe=True)
websession = aiohttp.ClientSession(cookie_jar=jar)

modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession)
await modem.login(password=sys.argv[2])

print("Disconnecting")
await modem.disconnect_lte()

print("Waiting 5 seconds")
await asyncio.sleep(5)

print("Connecting")
await modem.connect_lte()

print("Waiting 5 seconds")
await asyncio.sleep(5)

print("Closing down")
await modem.logout()
await websession.close()

if len(sys.argv) != 3:
print("{}: <netgear ip> <netgear password>".format(sys.argv[0]))
else:
asyncio.get_event_loop().run_until_complete(reconnect())