Skip to content

Instantly share code, notes, and snippets.

@rochmad
Created November 15, 2020 06:26
Show Gist options
  • Save rochmad/adfd108f8b67de6c7a577bbebac433a3 to your computer and use it in GitHub Desktop.
Save rochmad/adfd108f8b67de6c7a577bbebac433a3 to your computer and use it in GitHub Desktop.
Huawei E5372(Bolt) signal and speed monitor
#!/usr/bin/python3
#for
#pip install huawei-lte-api
from huawei_lte_api.Client import Client
from huawei_lte_api.AuthorizedConnection import AuthorizedConnection
from huawei_lte_api.Connection import Connection
from reprint import output
import time
from huawei_lte_api.enums.sms import BoxTypeEnum
# connection = Connection('http://192.168.8.1/') For limited access, I have valid credentials no need for limited access
# 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
#connection = AuthorizedConnection('http://admin:admin@192.168.8.1/')
#print("client connection")
#client = Client(connection) # This just simplifies access to separate API groups, you can use device = Device(connection) if you want
#print("trafic statistics" )
#print(client.monitoring.traffic_statistics())
#print("month statistics" )
#print(client.monitoring.month_statistics())
def main():
connection = AuthorizedConnection('http://admin:admin@192.168.8.1/')
with output(output_type='dict') as output_lines:
while True:
try:
client = Client(connection)
sig = client.device.signal()
# print(sig)
rsrp = sig["rsrp"]
rsrq = sig["rsrq"]
sinr = sig["sinr"]
rssi = sig["rssi"]
mode = sig["mode"]
cell_id = sig["cell_id"]
bdw = client.monitoring.traffic_statistics()
#download = int(bdw['CurrentDownloadRate'])*8//(1024*1024)
download = int(bdw['CurrentDownloadRate'])/100
upload = int(bdw['CurrentUploadRate'])/100
totaldownload = int(bdw['TotalDownload'])*8//(1024*1024)
totalupload = int(bdw['TotalUpload'])*8//(1024*1024)
# print(download, "Kbps")
# print(upload, "Kbps")
# print(totaldownload)
print("CELLID : ", cell_id, "RSRP : ", rsrp, "RSRQ : ", rsrp, "\tRSSI :", rssi, "SINR :", sinr, "MODE : ", mode, "\t", "DOWNLOADS(kbps) : ", download, "\t", "UPLOAD(kbps) : ", upload )
time.sleep(1)
except ResponseErrorLoginCsfrException:
connection = AuthorizedConnection('http://admin:admin@192.168.8.1/')
client.user.logout()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment