· 4 years ago · Jul 16, 2021, 10:34 AM
1from huawei_lte_api.Client import Client
2from huawei_lte_api.AuthorizedConnection import AuthorizedConnection
3from huawei_lte_api.Connection import Connection
4import keyboard # using module keyboard
5
6# connection = Connection('http://192.168.8.1/') For limited access, I have valid credentials no need for limited access
7# connection = AuthorizedConnection('http://admin:MY_SUPER_TRUPER_PASSWORD@192.168.8.1/', login_on_demand=True) # If you wish to login on demand (when call requires authorization), pass login_on_demand=True
8connection = AuthorizedConnection('http://admin:MY_SUPER_TRUPER_PASSWORD@192.168.8.1/')
9
10client = Client(connection) # This just simplifies access to separate API groups, you can use device = Device(connection) if you want
11
12bandsList = [
13 ('b1', 'FDD', '2100', '1'),
14 ('b2', 'FDD', '1900', '2'),
15 ('b3', 'FDD', '1800', '4'),
16 ('b4', 'FDD', '1700', '8'),
17 ('b5', 'FDD', '850', '10'),
18 ('b6', 'FDD', '800', '20'),
19 ('b7', 'FDD', '2600', '40'),
20 ('b8', 'FDD', '900', '80'),
21 ('b19', 'FDD', '850', '40000'),
22 ('b20', 'FDD', '800', '80000'),
23 ('b26', 'FDD', '850', '2000000'),
24 ('b28', 'FDD', '700', '8000000'),
25 ('b32', 'FDD', '1500', '80000000'),
26 ('b38', 'TDD', '2600', '2000000000'),
27 ('b40', 'TDD', '2300', '8000000000'),
28 ('b41', 'TDD', '2500', '10000000000'),
29]
30
31lteband = "40" # Manual choice
32networkband = "3FFFFFFF"
33networkmode = "03"
34
35status=True
36
37while True:
38 try:
39 keyboard.wait("/")
40 print("Reconnecting")
41 if status==True:
42 lteband="40"
43 status=False
44 else:
45 lteband="4"
46 status=True
47
48 client.net.set_net_mode(lteband, networkband, networkmode)
49
50 except:
51 break # if user pressed a key other than the given key the loop will break
52
53print(client.device.signal()) # Can be accessed without authorization
54
55print("\n\n\n")
56
57print(client.device.information()) # Needs valid authorization, will throw exception if invalid credentials are passed in URL
58
59print("\n\n\n")
60
61# For more API calls just look on code in the huawei_lte_api/api folder, there is no separate DOC yet
62