D10解决录音死机问题与k01解决视频通话死机问题更新,未验证
authorp15692025051 <846603105@qq.com>
Tue, 28 Nov 2023 10:23:00 +0000 (18:23 +0800)
committerp15692025051 <846603105@qq.com>
Tue, 28 Nov 2023 10:23:00 +0000 (18:23 +0800)
14 files changed:
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/constants.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/main_init.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/mgr.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/protocol.py
2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/sleep_test.py
2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/DBG.7z
2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip
2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/libHeliosAPI.lib
2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/ql_common_api.lib
2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/DBG.7z
2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip
2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/libHeliosAPI.lib
2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/ql_common_api.lib

index 6cbd554..6b4477d 100644 (file)
@@ -87,7 +87,7 @@ class intervManager(Abstract):
 
         self.record_test = audio.Record()
         self.record_test.gain(4,12)
-
+        self.wechat_record_flag = 0
         self.timeSecond = 0
         self.wechat_show = 0
         self.sort_new = {}
@@ -191,7 +191,7 @@ class intervManager(Abstract):
 
 
         EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件
-        
+        EventMesh.subscribe("get_wechat_record_flag", self.get_wechat_record_flag) #获取是否在录音表示
 
     def sos_short_press(self,args,msg):
         EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话
@@ -1458,7 +1458,9 @@ class intervManager(Abstract):
 
     def get_wechat_time(self, event, msg):
         return  [self.press_btn,self.timeSecond]
-
+    
+    def get_wechat_record_flag(self, event, msg):
+        return self.wechat_record_flag 
     def start_wechat_record(self, event, msg): #开始录音相关配置
         if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
 
@@ -1480,6 +1482,7 @@ class intervManager(Abstract):
                         self.wechat_num = 0 
                     self.wechat_num += 1
                     self.wechat_show = self.wechat_num
+                    self.wechat_record_flag =  1
                     self.record_test.start("/usr/static/storage_file/{}.amr".format(self.wechat_show),16) 
         else:
            self.timeSecond = 0
@@ -1495,7 +1498,6 @@ class intervManager(Abstract):
             EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
             # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.OPEN_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#測量成功
             self.countdown_old = 0
-
             date_tmp = utime.localtime()
             time_tmp = utime.mktime(date_tmp)
 
@@ -1510,12 +1512,9 @@ class intervManager(Abstract):
                 self.wechat_recode_list["num"] = self.wechat_show
                 EventMesh.debug_log("self.wechat_recode_list :{}".format(self.wechat_recode_list))
 
-
-
                 with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
                     ujson.dump(self.wechat_recode_list,fd)
-                # EventMesh.debug_log("send wechat data!!!!!!!!!!!!!!!!!!!!!")
-
+                 
                 check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show))
                 if check_txt == True :
                     path = "/usr/static/storage_file/{}.amr".format(self.wechat_show)
@@ -1523,9 +1522,8 @@ class intervManager(Abstract):
                         buf = bytearray(ql_fs.path_getsize(path))
                         fd.readinto(buf)
                         senddata = [self.countdown_old,buf]
-                        EventMesh.publish(constants.PROTOCOL.TK_SEND,senddata)
-                
-                
+                        EventMesh.publish(constants.PROTOCOL.TKS_SEND,senddata)
+        self.wechat_record_flag =  0
                 # check_txt = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(self.wechat_show))
                 # if check_txt == True :
                 #     path = "/usr/static/storage_file/{}.amr".format(self.wechat_show)
index 329e698..7c6828f 100644 (file)
@@ -26,6 +26,9 @@ class PROTOCOL:
     TK_SEND = "TK_SEND"
     TK_RECV = "TK_RECV"
 
+    TKS_SEND = "TKS_SEND"
+    TKS_RECV = "TKS_RECV"
+
     MESSAGE_SEND = "MESSAGE_SEND"
     MESSAGE_RECV = "MESSAGE_RECV"
 
index 14c9530..ffc1bad 100644 (file)
@@ -74,7 +74,7 @@ def main_init():
     
 
     from protocol import MESSAGE_ProtoCol,TK_ProtoCol,LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,\
-        TEMP_ProtoCol,DLT_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,Time_ProtoCol,\
+        TEMP_ProtoCol,DLT_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,Time_ProtoCol,TKS_ProtoCol,\
             ProtoColResolver,SILENCETIME2_ProtoCol,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol,WDSTART_ProtoCol,LOWBAT_ProtoCol,sosHome_dial_ProtoCol,SockManager,NetManager
         
     import mgr as mgr
@@ -157,6 +157,7 @@ def main_init():
     pcr.add_support(POWEROFF_ProtoCol())
     pcr.add_support(PHL_ProtoCol())
     pcr.add_support(TK_ProtoCol())
+    pcr.add_support(TKS_ProtoCol())
     pcr.add_support(MESSAGE_ProtoCol())
     pcr.add_support(WT_ProtoCol())
     pcr.add_support(REMIND_ProtoCol())
index caf01df..43b2390 100644 (file)
@@ -3444,8 +3444,8 @@ class deleteSmsManager(Abstract):#删除信息
         sms.deleteMsg(1,4)
 
 #闹钟信息
-alarm_list = [{'hour': 23, 'repeart': 10, 'idx': 0, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 0},
-               {'hour': 6, 'repeart': 10, 'idx': 1, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 0},
+alarm_list = [{'hour': 6, 'repeart': 10, 'idx': 0, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 0},
+               {'hour': 23, 'repeart': 10, 'idx': 1, 'enabled': 1, 'days': [0,1,2,3,4,5,6], 'minute': 0},
                {'hour': 16, 'repeart': 10, 'idx': 2, 'enabled': 0, 'days': [], 'minute': 39},
                {'hour': 16, 'repeart': 10, 'idx': 3, 'enabled': 0, 'days': [], 'minute': 39},
                {'hour': 16, 'repeart': 10, 'idx': 4, 'enabled': 0, 'days': [], 'minute': 39}]
index 8efcbdf..412d6d9 100644 (file)
@@ -281,8 +281,7 @@ class SockManager(Abstract):
    
                 data = data + r
                 EventMesh.debug_log("TCP recv: data:len:{}".format(len(data)))
-                
-                EventMesh.debug_log("TCP recv: data:{}".format(data))
+                #EventMesh.debug_log("TCP recv: data:{}".format(data))
                 if data[-1] != 0x5d and len(data)<20*1024: #']':
                     continue
                 self.connect_tmp = 1 #有数据,就认为是连接状态
@@ -1443,16 +1442,142 @@ class TK_ProtoCol(ProtoCol):
     
 
     def send(self, event, msg):
-        # EventMesh.debug_log("TK send:{}".format(msg))
+        EventMesh.debug_log("TK send:")
         if len(str(msg)) == 1:
 
+            len_size = len(str(msg))+len("TK,")
+            #  实例:[XT*334588000000156*0009*TK,1]
+            send_data = self.PID+"*%s*%04X*TK"%(self.imei,len_size)
+            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"TK")
+            MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+            data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
+            EventMesh.debug_log("TK:data:%s"%(data))
+            # 通过socket发送到服务器端
+            EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+        else:
+            # [SZKW*YYYYYYYYYYYYYYY*LEN*TK,AMR 格式音频数据]
+            #[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
+            arm_data = msg[1]
+            arm_sec = msg[0]
+            # EventMesh.debug_log("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
+
+            arm = bytearray()
+            for i in range(len(arm_data)):
+                if arm_data[i] == 0x7d:
+                    arm.extend(b'\x7d\x01')
+                elif arm_data[i] == 0x5b :
+                    arm.extend(b'\x7d\x02')
+                elif arm_data[i] == 0x5d :
+                    arm.extend(b'\x7d\x03')
+                elif arm_data[i] == 0x2c :
+                    arm.extend(b'\x7d\x04')
+                elif arm_data[i] == 0x2a :
+                    arm.extend(b'\x7d\x05')
+                else :
+                    arm.append(arm_data[i])
+                
+            datalen = len(arm) + 4+len(str(arm_sec))+1
+            #Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
+            send_data = bytearray("SZKW*%s*%04X*TK,%d,"%(self.imei,datalen,arm_sec))
+            send_data.extend(arm)
+            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,datalen,"TK")
+            MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+            data = bytearray('[')
+            data.extend(MD5_SIGN)
+            data.extend(send_data)
+            data.extend(']')
+            # EventMesh.debug_log("TK:send data:%s MD5_head_data:%s"%(data,MD5_head_data))
+            EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+
+    def recv(self, event, msg):
+        """
+
+        ("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+        @param event: 微聊
+        @param msg: 接收到的下行数据
+        [SZKW*860132060004322*20BD*TK,#!AMR...]
+        """
+        #Wechat_log("K_ProtoCol:recv:data:{}".format(msg))
+        
+        msg_tmp = msg.decode('ascii')
+        str = msg_tmp.split('TK,')
+        # Wechat_log("TK_ProtoCol:recv:len:{} {} {}".format(len(msg),len(str),msg_tmp.find("#!AMR")))
+
+        read_AMR_flag = msg_tmp.find("#!AMR")
+        #EventMesh.debug_log("TK recv:read_AMR_flag:{} ,{}".format(read_AMR_flag,EventMesh.publish("get_wechat_record_flag")))
+        if  EventMesh.publish("get_wechat_record_flag") != 1 and  read_AMR_flag != -1: #是否是服务器下发音频数据
+            # Wechat_log("TK_ProtoCol:recv:datalen{}".format(len(msg)))
+            arm_data = bytearray(str[1])#获取amr输出
+            get_wechat_data = EventMesh.publish("get_wechat_data")
+            MXA_MSG = get_wechat_data[0]
+            wechat_recode_list = get_wechat_data[1]
+            wechat_num = int(wechat_recode_list["num"])
+            # Wechat_log("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+            
+            if wechat_num >= MXA_MSG:
+                wechat_num = 0 
+            if wechat_num == 0:
+                wechat_num += 1 
+            elif wechat_num > 0:
+                wechat_num += 1 
+
+
+            EventMesh.debug_log("num_total:datalen:{} {}".format(MXA_MSG,wechat_recode_list))
+            wechat_recode_list["%02d"%(wechat_num)] = "read:1"
+            wechat_recode_list['num'] = wechat_num
+            EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_recode_list])
+            #写语音文件数据
+
+            # path = "/usr/static/storage_file/wechat.amr"
+            path = "/usr/static/storage_file/{}.amr".format(wechat_num)
+            with open(path,"w") as fd:
+                arm = bytearray()
+                j = 0
+                for i in range(len(arm_data)):
+                    if arm_data[j] == 0x7d and arm_data[j+1] == 0x01:
+                        arm.extend(b'\x7d')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x02:
+                        arm.extend(b'\x5b')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x03:
+                        arm.extend(b'\x5d')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x04:
+                        arm.extend(b'\x2c')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x05:
+                        arm.extend(b'\x2a')
+                        j+=1
+                    else :
+                        arm.append(arm_data[j])
+                    j+=1
+                    if j >= len(arm_data):
+                        break
+                fd.write(arm)
+            EventMesh.publish("recv_wechat_audio")#
+            EventMesh.publish(constants.PROTOCOL.TK_SEND,1)
+            EventMesh.debug_log("constants.PROTOCOL.TK_SEND1!!!")
+        else :
+            if read_AMR_flag != -1:
+                EventMesh.publish(constants.PROTOCOL.TK_SEND,0)
+        
+class TKS_ProtoCol(ProtoCol):
+    """微聊"""
+    TYPE = "TKS"
+    
+
+    def send(self, event, msg):
+        EventMesh.debug_log("TKS send:")
+        if len(str(msg)) == 1:
             len_size = len(str(msg))+len("TKS,")
             #  实例:[XT*334588000000156*0009*TK,1]
             send_data = self.PID+"*%s*%04X*TKS"%(self.imei,len_size)
             MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"TKS")
             MD5_SIGN = self.pack_MD5_head(MD5_head_data)
             data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
-            EventMesh.debug_log("TK:data:%s"%(data))
+            EventMesh.debug_log("TKS:data:%s"%(data))
             # 通过socket发送到服务器端
             EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
         else:
@@ -1460,7 +1585,7 @@ class TK_ProtoCol(ProtoCol):
             #[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
             arm_data = msg[1]
             arm_sec = msg[0]
-            # EventMesh.debug_log("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
+            EventMesh.debug_log("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
 
             arm = bytearray()
             for i in range(len(arm_data)):
@@ -1502,9 +1627,10 @@ class TK_ProtoCol(ProtoCol):
         #Wechat_log("K_ProtoCol:recv:data:{}".format(msg))
         # EventMesh.debug_log("TK recv:{}".format(msg))
         msg_tmp = msg.decode('ascii')
-        str = msg_tmp.split('TK,')
+        str = msg_tmp.split('TKS,')
         # Wechat_log("TK_ProtoCol:recv:len:{} {} {}".format(len(msg),len(str),msg_tmp.find("#!AMR")))
-        if  msg_tmp.find("#!AMR") != -1: #是否是服务器下发音频数据
+        read_AMR_flag = msg_tmp.find("#!AMR")
+        if  EventMesh.publish("get_wechat_record_flag") != 1 and  read_AMR_flag != -1: #是否是服务器下发音频数据
             # Wechat_log("TK_ProtoCol:recv:datalen{}".format(len(msg)))
             arm_data = bytearray(str[1])#获取amr输出
             get_wechat_data = EventMesh.publish("get_wechat_data")
@@ -1554,12 +1680,17 @@ class TK_ProtoCol(ProtoCol):
                     if j >= len(arm_data):
                         break
                 fd.write(arm)
-            EventMesh.publish(constants.PROTOCOL.TK_SEND,1)
             EventMesh.publish("recv_wechat_audio")#
+            EventMesh.publish(constants.PROTOCOL.TKS_SEND,1)#返回接收成功
+        else :
+            if read_AMR_flag != -1 :
+                EventMesh.publish(constants.PROTOCOL.TKS_SEND,0)#返回接收失败
+        
 
             
             
             
+            
 
 class MESSAGE_ProtoCol(ProtoCol):
     """微聊"""
index 7631a1a..354a47c 100644 (file)
@@ -1,5 +1,6 @@
 import uos
 import ql_fs
+import EventMesh
 if ql_fs.path_exists("/ext") == False:
     ldev = uos.VfsLfs1(32, 32, 32, "ext_fs",0,3)
     uos.mount(ldev,'/ext')
index 0b5c319..bbe1f4a 100644 (file)
Binary files a/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/DBG.7z and b/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/DBG.7z differ
index 3d2fb11..fc5cf21 100644 (file)
Binary files a/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip and b/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip differ
index 072d314..714d069 100644 (file)
Binary files a/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/libHeliosAPI.lib and b/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/libHeliosAPI.lib differ
index 525a1f3..c0f815c 100644 (file)
Binary files a/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/ql_common_api.lib and b/2.sdk/project/D10/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/ql_common_api.lib differ
index 0b5c319..bbe1f4a 100644 (file)
Binary files a/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/DBG.7z and b/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/DBG.7z differ
index cea55d7..116856a 100644 (file)
Binary files a/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip and b/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/images/firmware_base_release_pack.zip differ
index 072d314..714d069 100644 (file)
Binary files a/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/libHeliosAPI.lib and b/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/libHeliosAPI.lib differ
index 525a1f3..c0f815c 100644 (file)
Binary files a/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/ql_common_api.lib and b/2.sdk/project/K01/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_VOLTE/libraries/ql_common_api.lib differ