url = "http://app.api.thisiot.com/dev/device/check?imei={}&bid={}&sonce={}&sign={}".format(imei,pid_data,sonce_data,sign_data)
# print("url:{}".format(url))
- response = request.get(url)
- data_tmp ={}
+ data_tmp = {}
+ connect_flag = 0
+ try:
+ response = request.get(url)
+ connect_flag = 1
+ except Exception as e:
+ usys.print_exception(e)
+
# d_server_addr = "device.miwitracker.com"
# d_server_port = 8505
# d_md5_key = ""
# d_PID = "3G"
# response.content = {'protocolType': '', 'host': 'device.miwitracker.com', 'secretKey': '', 'port': 8505, 'bid': '3G', 'extJsonStr': ''}
# response.status_code=200
- print("test-{}".format(response.status_code))
- if response.status_code == 200:
- content = response.content
- c = next(content)
- # "api.xcloudtech.com"
- # d_server_port = 9000
- jsload_data = ujson.loads(c)
- print("jsload_data-{}".format(jsload_data))
- # jsload_data = {'data':'111','protocolType':'', 'host':'device.miwitracker.com', 'secretKey': 'bZld0ALsZTt15tKEZhOlLPgbsO75BLTP', 'port':8505, 'bid': '3G', 'extJsonStr': ''}
- # ujson.loads(c)
-
- if "success" in jsload_data:
- success = jsload_data["success"]
- if success == True:#合法设备
- if "data" in jsload_data:
- data_tmp = jsload_data["data"]#返回的数据
- print("data_tmp:{}".format(data_tmp))
- code = jsload_data["code"]
- if code == 20000:#合法的设备
- protocloType = data_tmp["protocolType"]#协议类型
- host = data_tmp["host"]#服务骑地址
- secretKey = data_tmp["secretKey"]#
- pid = data_tmp["bid"]#产品型号
- port = data_tmp["port"]#端口号
-
-
-
- if host != '' and (port != '' and port != -1):
- if host != '':
- self.server_addr = host
- EventMesh.publish("set_ip",str(self.server_addr))
-
- if port != '' and port != -1:
- self.server_port = port
- EventMesh.publish("set_com",self.server_port)
- EventMesh.publish("set_new_key", str(secretKey))#获取pid和key
- EventMesh.publish("set_new_pid",str(pid))#获取pid和key
- # self.reconnect_timer_cb()#重连设备
- print("self.reconnect_flag",self.reconnect_flag)
- self.reconnect_flag = 0
- self.reconnect()#重连设备
+ print("connect_flag:{}\r\n".format(connect_flag))
+ if connect_flag == 1:
+ print("response.status_code:{} connect_flag:{}\r\n".format(response.status_code,connect_flag))
+ if response.status_code == 200:
+ content = response.content
+ c = next(content)
+ # "api.xcloudtech.com"
+ # d_server_port = 9000
+ jsload_data = ujson.loads(c)
+ print("jsload_data-{}".format(jsload_data))
+ # jsload_data = {'data':'111','protocolType':'', 'host':'device.miwitracker.com', 'secretKey': 'bZld0ALsZTt15tKEZhOlLPgbsO75BLTP', 'port':8505, 'bid': '3G', 'extJsonStr': ''}
+ # ujson.loads(c)
+
+ if "success" in jsload_data:
+ success = jsload_data["success"]
+ if success == True:#合法设备
+ if "data" in jsload_data:
+ data_tmp = jsload_data["data"]#返回的数据
+ print("data_tmp:{}".format(data_tmp))
+ code = jsload_data["code"]
+ if code == 20000:#合法的设备
+ protocloType = data_tmp["protocolType"]#协议类型
+ host = data_tmp["host"]#服务骑地址
+ secretKey = data_tmp["secretKey"]#
+ pid = data_tmp["bid"]#产品型号
+ port = data_tmp["port"]#端口号
+
+ if secretKey != '' and secretKey != -1:
+ EventMesh.publish("set_new_key", str(secretKey))#获取pid和key
+ if pid != '' and pid != -1:
+ EventMesh.publish("set_new_pid",str(pid))#获取pid和key
+
+ if host != '' and (port != '' and port != -1):
+ if host != '':
+ self.server_addr = host
+ EventMesh.publish("set_ip",str(self.server_addr))
+
+ if port != '' and port != -1:
+ self.server_port = port
+ EventMesh.publish("set_com",self.server_port)
+
+ # self.reconnect_timer_cb()#重连设备
+ print("self.reconnect_flag",self.reconnect_flag)
+ self.reconnect_flag = 0
+ self.reconnect()#重连设备
+ self.publish_timer.stop()
+ EventMesh.publish("set_server_state",1)#获取修改服务器状态
+ else:
self.publish_timer.stop()
- EventMesh.publish("set_server_state",1)#获取修改服务器状态
else:
self.publish_timer.stop()
+
+
def check(self, *args):
if (not self.run_flag) or (self.connect_tmp == 0) : #7分钟无数据读取,则认为是掉线了
print("tcp reconnect!!!!!!!!!!!!!!!!!!")
# print("video call_state",call_state)
if call_state != 5:
self.time_out+=1
- if self.time_out >= 60 or (call_state == 0 and self.time_out >= 2 and self.statu_open != 1):
+ if self.time_out >= 60 or (call_state == 0 and self.time_out >= 5 and self.statu_open != 1):
self.time_out = 0
self.timer.stop()
# print("video call_state",call_state)
def post_processor_after_initialization(self):
global voice_call_screen,voice_call_img,voice_call_name_label,voice_call_answer,voice_call_hangup
- self.call_timer.start(6000, 1, self.call_timer_cb)
+ self.call_timer.start(4000, 1, self.call_timer_cb)
self.timeout = 0
self.call_timer1.start(1*1000, 1, self.get_video_state)
self.aud.play(1, 1, 'U:/static/audio_audio_haixiu.mp3') #播放来电铃声
EventMesh.publish("publish_message_event_ui",{"func":self.get_video_state_cb,"data":0})
def get_video_state_cb(self,data):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
call_state = jrtc.get_state()
# print("vedio_incall",call_state)
self.timeout+=1
def post_processor_after_initialization(self):
global vedio_call_screen,vedio_call_img,vedio_call_name_label,vedio_call_answer,vedio_call_hangup
- self.call_timer.start(6000, 1, self.call_timer_cb)
+ self.call_timer.start(4000, 1, self.call_timer_cb)
self.timeout = 0
self.call_timer1.start(1*1000, 1, self.get_video_state)
self.aud.play(1, 1, 'U:/static/audio_audio_haixiu.mp3') #播放来电铃声
EventMesh.publish("publish_message_event_ui",{"func":self.get_video_state_cb,"data":0})
def get_video_state_cb(self,data):
+ EventMesh.publish("system_sleep_rest")#防止黑屏
call_state = jrtc.get_state()
# print("vedio_incall",call_state)
self.timeout+=1
self.second_count += 1
self.show_time()
- if call_state != 5:#未接通 1分钟未接通挂断或者 接通后app 网络不好也主动手表挂断
+ if call_state != 5 :#未接通 1分钟未接通挂断或者 接通后app 网络不好也主动手表挂断
self.time_count+=1
if self.time_count >= 1*60 or (call_state == 0 and self.time_count >= 5 and self.answer != 1):
self.time_count = 0