forked from Salamek/huawei-lte-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitial_setup_e5576-320.py
69 lines (52 loc) · 2.01 KB
/
initial_setup_e5576-320.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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('--newpassword', type=str)
parser.add_argument('--ssid', type=str)
parser.add_argument('--wpapassword', type=str)
args = parser.parse_args()
original_password = args.password
new_password = args.newpassword
wifi_ssid = args.ssid
wifi_password = args.wpapassword
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