Created
December 30, 2022 20:03
-
-
Save theundefined/143c427518bb0bbb146ae4bbf7e2e2b3 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python3 | |
import requests | |
import re | |
import math | |
def transTemperature(v): | |
# function transTemperature(temperature){ | |
# var temp = Number(temperature); | |
# if (temp >= Math.pow(2, 15)){ | |
# return -Math.round((Math.pow(2, 16)-temp)/256); | |
# }else{ | |
# return Math.round(temp/256); | |
# } | |
if(v>math.pow(2,15)): | |
return - (math.pow(2,16)-v)/256 | |
else: | |
return v/256 | |
url='http://192.168.33.1/cgi-bin/status_deviceinfo.asp' | |
authorization='dXNlcmFkbWluOnVzZXJhZG1pbjEyMw==' | |
cookie='SESSIONID=0' | |
r=requests.get(url, headers={"Authorization":"Basic " + authorization,"Cookie": cookie}) | |
values=re.findall("Number\((\d+)\)",r.text) | |
temperaturev=re.findall("transTemperature\((\d+)\)",r.text) | |
rxpower=math.log(float(values[0])/10000) / math.log(10) * 10 | |
txpower=math.log(float(values[1])/10000) / math.log(10) * 10 | |
# document.write((Number(6398)*2/1000)+" mA"); | |
txbias=float(values[2])*2/1000 | |
supplyvoltage=float(values[3])/1000 | |
temperature=transTemperature(float(temperaturev[0])) | |
print("RxPower:", rxpower) | |
print("TxPower:", txpower) | |
print("TxBiasCurrent:", txbias) | |
print("SupplyVoltage:", supplyvoltage) | |
print("Temperature:", temperature) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment