def authen_set(self):
sever_state = EventMesh.publish("get_server_state")#获取修改服务器状态
+ # print("sever_state{}".format(sever_state))
if sever_state != None:
if sever_state == 0:
imei = EventMesh.publish(constants.EVENT.GET_IMEI)
# 转成十六进制表示
sign_data = ubinascii.hexlify(res)
sign_data = sign_data.decode('ascii')
- print("sign_data:{} sonce_data:{}".format(md5_data,sign_data))
+ # print("sign_data:{} sonce_data:{}".format(md5_data,sign_data))
# sign_data = MD5_head
# http://8.134.110.49:31379/dev/device/check?imei=&bid=sonce=sign=
- ip_addr = "iot.api.thisiot.com"
- # url = "http://{}/dev/device/check?imei={}&bid={}&sonce={}&sign={}".format(ip_addr,imei,pid_data,sonce_data,sign_data)
+ # ip_addr = "test.iot.api.thisiot.com"
+ # ip_addr = "app.api.thisiot.com"
+ # http://app.api.thisiot.com/
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 ={}
# d_server_addr = "device.miwitracker.com"
# "api.xcloudtech.com"
# d_server_port = 9000
jsload_data = ujson.loads(c)
- # print("jsload_data-{}".format(jsload_data))
+ 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)
host = data_tmp["host"]#服务骑地址
secretKey = data_tmp["secretKey"]#
pid = data_tmp["bid"]#产品型号
- port = data_tmp["port"]#端口
- if host != '' and port != '' and port != -1:
+ 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()#重连设备
- EventMesh.publish("set_server_state",1)#获取修改服务器状态
-
-
-
+ 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分钟无数据读取,则认为是掉线了