-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
wlan_guide_settings api #219
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6402b09
WIP: first version of the configuration of the router via the guide api
timvlaer a968bb9
Fix "accept privacy policy" api
timvlaer d9efc50
Reformat set_wlan_guide_settings
timvlaer 47be794
Example script for setup of E5576-320
timvlaer 1684f36
Fix linting issues
timvlaer 1cbe6e0
Fix linting issues (2)
timvlaer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from argparse import ArgumentParser | ||
|
||
from huawei_lte_api.Client import Client | ||
from huawei_lte_api.Connection import Connection | ||
from time import sleep | ||
|
||
parser = ArgumentParser() | ||
parser.add_argument('--password', type=str) | ||
parser.add_argument('--new-password', type=str) | ||
parser.add_argument('--ssid', type=str) | ||
parser.add_argument('--wpa-password', type=str) | ||
args = parser.parse_args() | ||
|
||
original_password = args["password"] | ||
new_password = args["new-password"] | ||
|
||
wifi_ssid = args["ssid"] | ||
wifi_password = args["wpa-password"] | ||
|
||
url = 'http://192.168.8.1/' | ||
with Connection(url, password=original_password) as connection: | ||
client = Client(connection) | ||
|
||
locale = "en-us" | ||
print("Set language to " + locale) | ||
print(client.language.set_current_language(locale)) | ||
|
||
print("Accept privacy policy") | ||
print(client.app.accept_privacypolicy(approve=True)) | ||
|
||
print("Set autoupdate config") | ||
print(client.online_update.set_autoupdate_config(autoupdate=True)) | ||
|
||
print("Set basic information") | ||
print(client.device.set_basic_information()) | ||
|
||
print(f"Set wlan ({wifi_ssid}/{wifi_password}) and account settings (admin/{new_password})") | ||
resp = client.wlan.set_wlan_guide_settings( | ||
ssid=wifi_ssid, wpa_psk=wifi_password, current_password=original_password, new_password=new_password | ||
) | ||
print(resp) | ||
|
||
print("Admin password changed, reconnect...") | ||
sleep(10) | ||
failing = True | ||
while failing: | ||
try: | ||
with Connection(url, password=new_password) as connection: | ||
print("Get basic information") | ||
status = client.monitoring.status() | ||
if status["ConnectionStatus"] == "901": | ||
failing = False | ||
else: | ||
sleep(60) | ||
except Exception as e: | ||
print("Failed with exception: " + str(e) + ", sleeping 60s") | ||
sleep(60) | ||
|
||
with Connection(url, password=new_password) as connection: | ||
client = Client(connection) | ||
|
||
print("Set basic information") | ||
print(client.device.set_basic_information()) | ||
|
||
# restart wifi to see effect of the new ssid | ||
# see toggle_wifi.py | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be _LOGGER.debug, _LOGGER.info or _LOGGER.warning so we do not pollute stdout with potentially unwanted text...