diff --git a/code/lan_ewlink_api.py b/code/lan_ewlink_api.py index ff0dd18..67779ce 100644 --- a/code/lan_ewlink_api.py +++ b/code/lan_ewlink_api.py @@ -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): """ @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) \ No newline at end of file + return self.send_data(send_url=url, send_data=data) diff --git a/code/tool_01DIY85.py b/code/tool_01DIY85.py old mode 100644 new mode 100755 index 308cd5e..f2ea5ef --- a/code/tool_01DIY85.py +++ b/code/tool_01DIY85.py @@ -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 @@ -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):