修改 cat1 python的tcp控制逻辑
authorhcj <1224667075@qq.com>
Fri, 24 Oct 2025 09:18:23 +0000 (17:18 +0800)
committerhcj <1224667075@qq.com>
Fri, 24 Oct 2025 09:18:23 +0000 (17:18 +0800)
cat1modem/src/cat1Service.py
cat1modem/src/tcpserver.py

index 5551b2c..d7515e7 100644 (file)
@@ -55,6 +55,7 @@ import ujson
 from usr.EventMesh import eventMesh
 
 from usr.httpota import httpota
+from usr.tcpserver import TcpServiceInit
 # from usr.telecom_dmp import telecomDmpCb
 # from usr.china_mobile_dmp import chinamobileCb
 
@@ -81,7 +82,7 @@ sms.setCallback(msg_cb)#sms注册回调
 CAT1_SERVICE_HEAD = 'FE' #固定head 
 
 PROJECT_NAME = "Cat1SlipUDPService"
-PROJECT_VERSION = "PY_SRV_V21"
+PROJECT_VERSION = "PY_SRV_V22"
 CONFIG_JSON="/usr/system_config.json"
 CURRENT_APP_TYPE="pysrv"
 
@@ -408,6 +409,9 @@ class Cat1Service:
             # UDP_MSG_OTA
         elif cmd == "1C":# 
             self.read_dev_ai_id()
+        elif cmd== "1D":
+            TcpService = TcpServiceInit()
+            TcpService.start_socket_thread()
         elif cmd == "AC":#
             if self.ack_sem==1:
                 self.ack_sem=0
index 080331b..aa0a0e5 100644 (file)
@@ -84,8 +84,7 @@ class TcpServiceInit:
         self.conn= None
         self.__sock_file = None
         self.__sock_file = self.__socket_file_init()
-        self.__thread_file = _thread.start_new_thread(self.__Socket_File_Thread, ())
-        self.conn_thread=_thread.start_new_thread(self._client_conn_proc, ())
+
 
     def __pack_tlv_format(self, head, content):
         head1 = head
@@ -153,7 +152,7 @@ class TcpServiceInit:
                 self.conn=cli_conn
                 clog.info('[serveice] accept a client: %s, %s' % (cli_ip_addr, cli_port))
             except :
-                utime.sleep_ms(2000) 
+                utime.sleep_ms(2000)
     
     def cat1FileTimerCb(self,*argc):
         clog.info("timer test\r\n")
@@ -596,7 +595,12 @@ class TcpServiceInit:
                     
     def otaTimeOut(self,*argc):
         clog.info("重启成功!!!!!!!!\r\n")
+        
+    def start_socket_thread(self):
+        __thread_file = _thread.start_new_thread(self.__Socket_File_Thread, ())
+        conn_thread=_thread.start_new_thread(self._client_conn_proc, ())
+
 
-TcpService = TcpServiceInit()
+# TcpService = TcpServiceInit()