Skip to content
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

Update tool_01DIY85.py #18

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions code/lan_ewlink_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,31 +183,31 @@ def performer_func(self, sub_id):
elif self. command_num == 7:
# 7 command("ROOT")
ret=self.get_signal_intensity(ip=ip,port=port,sub_id=sub_id)
elif self. command_num==8:
#8命令(获取设备状态信息)
ret=self.get_dev_info_api(ip=ip,port=port,sub_id=sub_id)
elif self. command_num==9:
#9命令(解锁ota)
print("self.command_vrg==",self.command_vrg)
ret=self.set_unlock(ip=ip,port=port,sub_id=sub_id)
print("ret",ret)
if ret['error'] == 0:
#10命令(发送升级信息)
ret=self.set_ota_flash(sha256sum= self.command_vrg["sha256sum"], sever_ip= self.command_vrg["sever_ip"], sever_port=self. command_vrg["sever_port"], ip=ip, port=port, sub_id=sub_id)
elif self. command_num == 8:
#8命令(获取设备状态信息)
ret=self.get_dev_info_api(ip=ip,port=port,sub_id=sub_id)
elif self. command_num==9:
#9命令(解锁ota)
print("self.command_vrg==",self.command_vrg)
ret=self.set_unlock(ip=ip,port=port,sub_id=sub_id)
print("ret",ret)
if ret['error'] == 0:
#10命令(发送升级信息)
ret=self.set_ota_flash(sha256sum= self.command_vrg["sha256sum"], sever_ip= self.command_vrg["sever_ip"], sever_port=self. command_vrg["sever_port"], ip=ip, port=port, sub_id=sub_id)
return ret

def send_data(self, send_url, send_data):
"""
send data to device by HTTP PORT
"""
"""
send data to device by HTTP PORT
"""
#try:
print("send:",send_url,str(send_data))
response =self.ht.postRequest(send_url,send_data)
print("response:",str(response))
if response["result"]:
return json.loads(response["text"])
else:
return 1
print("send:",send_url,str(send_data))
response =self.ht.postRequest(send_url,send_data)
print("response:",str(response))
if response["result"]:
return json.loads(response["text"])
else:
return 1

def set_OUT(self, **info):
"""
Expand All @@ -232,10 +232,10 @@ def set_OUT(self, **info):
data["sequence"] = str(int(time.time()))
sub_id = info["sub_id"]
data["deviceid"] = sub_id
if out_sta:
data["data"]= {"switch": "on"}
else:
data["data"]= {"switch": "off"}
if out_sta:
data["data"]= {"switch": "on"}
else:
data["data"]= {"switch": "off"}
# 3. Call Http_API(postRequest) to send.
return self.send_data(send_url=url, send_data=data)

Expand All @@ -262,12 +262,12 @@ def set_power_up_state(self, **info):
data["sequence"] = str(int(time.time()))
sub_id = info["sub_id"]
data["deviceid"] = sub_id
if(state== 0):
data["data"]= {"startup": "off"}
elif (state== 1):
data["data"]= {"startup": "on"}
elif (state== 2):
data["data"]= {"startup": "stay"}
if(state== 0):
data["data"]= {"startup": "off"}
elif (state== 1):
data["data"]= {"startup": "on"}
elif (state== 2):
data["data"]= {"startup": "stay"}
# 3. Call Http_API(postRequest) to send.
return self.send_data(send_url=url, send_data=data)

Expand Down Expand Up @@ -376,7 +376,7 @@ def set_unlock(self, **info):
data["sequence"] = str(int(time.time()))
sub_id = info["sub_id"]
data["deviceid"] = sub_id
data["data"]= { }
data["data"]= { }
# 3. Call Http_API(postRequest) to send.
return self.send_data(send_url=url, send_data=data)

Expand Down Expand Up @@ -405,7 +405,7 @@ def set_ota_flash(self, **info):
data["sequence"] = str(int(time.time()))
sub_id = info["sub_id"]
data["deviceid"] = sub_id
data["data"]= { }
data["data"]= { }
# 3. Call Http_API(postRequest) to send.
return self.send_data(send_url=url, send_data=data)

Expand All @@ -422,4 +422,4 @@ def get_dev_info_api(self,**info):
sub_id=info["sub_id"]
data["deviceid"]=sub_id
data["data"]= { }
return self.send_data(send_url=url, send_data=data)
return self.send_data(send_url=url, send_data=data)
4 changes: 2 additions & 2 deletions code/tool_01DIY85.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def add_line_item(self):
# Fill in the "Inching" button
b_inch = QTableWidgetItem("Inching")
self.ui.tableWidget.setItem(line_num, 7, b_inch)
# rssi
# rssi
newresultBItem=QTableWidgetItem(str(sub_sta_info["rssi"]))
self.ui.tableWidget.setItem(line_num,8,newresultBItem)
# Color according to the device information
Expand Down Expand Up @@ -430,7 +430,7 @@ def result_to_ui(self, result_str):
return
result_list = result_str.split("\n")
print("The return value is received:", result_list)
self.send_result[result_list[0]]=eval(result_list[1])
self.send_result[result_list[0]]=eval(result_list[1])


def run_detection(self, command_num, **comand_vrg):
Expand Down