K01鉴权优化
authordxy15521469561 <1731678236@qq.com>
Tue, 9 Apr 2024 10:02:39 +0000 (18:02 +0800)
committerdxy15521469561 <1731678236@qq.com>
Tue, 9 Apr 2024 10:02:39 +0000 (18:02 +0800)
2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/protocol.py

index 0e1a403..132b704 100644 (file)
@@ -192,6 +192,7 @@ class SockManager(Abstract):
 
     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)
@@ -219,13 +220,15 @@ class SockManager(Abstract):
                 # 转成十六进制表示
                 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"
@@ -241,7 +244,7 @@ class SockManager(Abstract):
                     # "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)
                     
@@ -257,8 +260,11 @@ class SockManager(Abstract):
                                     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))
@@ -266,15 +272,16 @@ class SockManager(Abstract):
                                         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分钟无数据读取,则认为是掉线了