修改了未读留言的bug
authorazao <821478748@qq.com>
Mon, 8 Dec 2025 03:29:42 +0000 (11:29 +0800)
committerazao <821478748@qq.com>
Mon, 8 Dec 2025 10:24:40 +0000 (18:24 +0800)
以及开机未读留言的提示
添加音量,设备号nlp查询
修改了多发语音60Sbug

2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py

index 91323ad..28248df 100644 (file)
@@ -2533,6 +2533,7 @@ class AI_VC(Abstract):
         EventMesh.subscribe("change_voice",self.change_voice) #改变音色
         EventMesh.subscribe("Close_VC",self.Close_VC) #外部结束对话
         EventMesh.subscribe("get_recv_voice",self.get_recv_voice) #获取留言播放状态
+        EventMesh.subscribe("set_recv_voice",self.set_recv_voice) #设置留言播放状态
         self.voice_timer = osTimer()#语音留言10S按下按键确定是否播放的判断定时器
         self.voice_cnt = 0 #留言定时器计数
         self.voicerupt_flag = 0#留言选择按键接听标志位
@@ -3476,6 +3477,7 @@ class AI_VC(Abstract):
         # return
         EventMesh.publish("exit_meet_mode")#退出会议纪要
         EventMesh.publish("exit_trans_mode")#退出AI翻译
+        EventMesh.publish("update_play_new_voice_info")#更新已读状态
         self.recv_voice = 0#退出留言以及留言查看
         EventMesh.publish("set_history_voice_flag",0)#修改标志位
         self.AI_new_voice_url = ""
@@ -4138,7 +4140,7 @@ class AI_VC(Abstract):
                             elif self.AI_TTS_str == "" and  self.AI_new_voice_url != "" and self.music_play_flag == 0:
                                 # if EventMesh.publish("get_history_voice_flag") == 1:
                                 EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_new_voice})#播放留言
-                                self.recv_voice = 0#当留言列表为空,留言播放标志清空
+                                # self.recv_voice = 0#当留言列表为空,留言播放标志清空
                                 # else:
                                 #     self.voice_cnt = 0
                                 #     print("定时器开启222222222")
@@ -4309,11 +4311,16 @@ class AI_VC(Abstract):
                         elif jsload_data["event"] == "audio.convert.completed":#音频转成完成没有出错 接口
                             
                             self.VC_state = VC_State_End
+                            print("未读留言初始数值:{}".format(self.pwk_cnt_voice))
                             if self.pwk_notice_flag == 1:#只有在播放的时候才会去计数
-                                self.pwk_cnt_voice -= 1#减1
-                                print("未读留言又-1,当前留言剩余数量为:{}".format(self.pwk_cnt_voice))
+                                if self.pwk_cnt_voice > 0:
+                                    self.pwk_cnt_voice -= 1#减1
+                                    print("未读留言又-1,当前留言剩余数量为:{}".format(self.pwk_cnt_voice))
+                                else:
+                                    print("未读列表为空")
                             if self.pwk_cnt_voice == 0:#积累的留言已经全部播完
                                 self.pwk_notice_flag = 0
+                                self.wait_first_flag = 0#让下次未读播放提示恢复
                                 self.voice_notice = 1#开启回复
                             if self.voice_choose_flag == 1:#播放完语音后,有冲突的时候关闭
                                 self.voice_choose_flag = 0
@@ -4341,6 +4348,7 @@ class AI_VC(Abstract):
                             #     EventMesh.publish("set_history_voice_flag",0)
                             EventMesh.publish("update_play_new_voice_info")#更新已读状态
                             self.recv_voice = 0
+                            print("不开启定时器标志位置0")
                             self.LocalRespondingEnded_timerout = 8
                             self.VC_state = VC_State_End
                                 
@@ -4418,12 +4426,12 @@ class AI_VC(Abstract):
         self.voice_cnt += 1
         # print("语音留言定时器cnt = {}".format(self.voice_cnt))
         if self.voicerupt_flag == 1:#按键被按下
-           self.pwk_notice_flag = 1#表示进入收听
+           self.pwk_notice_flag = 1#表示进入收听未听留言
            self.AI_VC_start()
            EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_new_voice})#播放留言
            self.voicerupt_flag = 0 #标志位置0
            self.voice_cnt = 0
-           self.recv_voice = 0#进入留言定时器,留言清空
+        #    self.recv_voice = 0#进入留言定时器,留言清空
            print("进入留言定时器1,留言清空!!!!!")
            EventMesh.publish("update_play_new_voice_info")#更新已读状态
            self.voice_timer.stop()
@@ -4473,6 +4481,7 @@ class AI_VC(Abstract):
     def wait_play_cb(self):
         self.wait_cnt += 1
         if self.voicerupt_flag == 1:#按键被按下
+           self.pwk_notice_flag = 1#表示进入收听未听留言
            self.AI_VC_start()
            EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_client_new_voice})#播放留言
            self.wait_cnt = 0
@@ -4496,7 +4505,8 @@ class AI_VC(Abstract):
         return self.voicerupt_flag
     def get_recv_voice(self,event,msg):
         return self.recv_voice
-
+    def set_recv_voice(self,event,msg):
+        return self.recv_voice
     def put_record_data(self,data):
         
         #print("下发音频数据1:{}".format(len(data[0])))
@@ -4965,15 +4975,15 @@ class AI_VC(Abstract):
                     #     else:
                     #         self.AI_TTS_str = "卡号查询失败"
                     #     return 0
-                    if text.find("设备号") != -1 :
-                        imei = modem.getDevImei()
-                        imei = num_str_to_chinese(imei)#转为中文
-                        if imei != -1 and len(imei) > 5:
-                            print("IMEI:{}".format(imei))
-                            self.AI_TTS_str = "当前设备号为:{}".format(imei)
-                        else:
-                            self.AI_TTS_str = "设备号查询失败"
-                        return 0
+                    # if text.find("设备号") != -1 :
+                    #     imei = modem.getDevImei()
+                    #     imei = num_str_to_chinese(imei)#转为中文
+                    #     if imei != -1 and len(imei) > 5:
+                    #         print("IMEI:{}".format(imei))
+                    #         self.AI_TTS_str = "当前设备号为:{}".format(imei)
+                    #     else:
+                    #         self.AI_TTS_str = "设备号查询失败"
+                    #     return 0
                     if text.find("版本") != -1 :
                         sourceVersion = versions.Build_Time
                         bt_versions = EventMesh.publish("get_bt_versions")
@@ -5701,6 +5711,18 @@ class AI_VC(Abstract):
             else:
                 tts_play_str = "卡号查询失败"
             EventMesh.publish("play_tts",[tts_play_str,1])
+        elif "设备号" in msg:
+            imei = modem.getDevImei()
+            if imei != -1 and len(imei) > 5:
+                print("IMEI:{}".format(imei))
+                tts_play_str = "当前设备号为:{}".format(imei)
+            else:
+                tts_play_str = "设备号查询失败"
+            EventMesh.publish("play_tts",[tts_play_str,1])
+        elif "音量" in msg :
+            tts_play_str = "当前音量是{}".format(self.VC_TTS_volume)
+            EventMesh.publish("play_tts",[tts_play_str,1])
+    
     #改变音色判断
     def change_voice(self,event ,msg):
         voice = msg
index e9d023d..e413945 100644 (file)
@@ -1901,7 +1901,9 @@ class SockMangager(Abstract):
                 device_state=EventMesh.publish("GET_IOT_WEB_SEND_CMD",WEB_CMD_ENUM.POST_DEVICE_STATE_S_CMD)
                 print("device_state{}".format(device_state))
                 EventMesh.publish(WEB_CMD_ENUM.POST_DEVICE_STATE_S_CMD,device_state) #上报设备状态
-
+                EventMesh.publish("set_open_device",1)
+                EventMesh.publish("set_history_voice_flag",1)
+                EventMesh.publish("set_wait_voice_flag",1)
                 EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S)#向IOT获取语音未读消息
             
         
@@ -2712,6 +2714,9 @@ def ai_cmd_handle(cmd):
         EventMesh.publish("SET_SPEECH_RATE",float(find))
         tts_play_str = "语速已经改为" + find
         EventMesh.publish("play_tts",[tts_play_str,0])
+    elif "这不支持哦,请换一个":
+        tts_play_str = "这个不支持哦,请换一个"
+        EventMesh.publish("play_tts",[tts_play_str,0])
 
 #NLP指令
 class IOTWeb_Nlp_ConfigProtoCol(ProtoCol):
@@ -3531,8 +3536,10 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
     def __init__(self):
         super().__init__()
         self.history_board_flag = 0#第一次进去要广播
+        self.open_device = 0#开机播报未读留言
         self.has_processed_history_voice = 0 #播完列表不许再拨“历史未读留言为空”
         EventMesh.subscribe("set_history_board_flag",self.set_history_board_flag)
+        EventMesh.subscribe("set_open_device",self.set_open_device)
     def send(self, event, msg):
 
         print("send find_voice_msg_list")
@@ -3550,6 +3557,8 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
         print("msg[\"data\"] = {}".format(voice_list))
         if EventMesh.publish("get_history_voice_flag") == 1:
             if len(voice_list) == 0:#为空
+                EventMesh.publish("set_history_voice_flag",0)
+                EventMesh.publish("set_wait_voice_flag",0)
                 if EventMesh.publish("get_wait_voice_flag") == 0:#未听历史留言
                     if self.has_processed_history_voice == 0:
                         tts_play_str = "历史未读留言列表为空"
@@ -3557,16 +3566,12 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
                     else:
                         self.has_processed_history_voice = 0#读完了置为0
                         self.history_board_flag = 0#广播置为0
-                    EventMesh.publish("set_history_voice_flag",0)#修改标志位
                     self.history_board_flag = 0
                     self.has_processed_wait_voice = 0
-                    EventMesh.publish("set_wait_voice_flag",0)#修改60S标志位
                     self.wait_first_flag = 0
                 else:#等待历史留言
                     self.has_processed_wait_voice = 0
                     self.wait_first_flag = 0
-                    EventMesh.publish("set_history_voice_flag",0)
-                    EventMesh.publish("set_wait_voice_flag",0)#修改60S标志位
             else:#有历史留言
                 if EventMesh.publish("get_wait_voice_flag") == 0:#历史留言
                     print("历史广播状态!!!!! = {}".format(self.history_board_flag))
@@ -3580,6 +3585,9 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
                     if len(new_voice_list) > 0:
                         pass
                 else:#未读留言
+                    if self.open_device == 1:
+                        EventMesh.publish("set_pwk_cnt_voice",len(voice_list))#设置未读次数,由于是开机一起查看的
+                        self.open_device = 0
                     for da in voice_list:
                         new_voice_list.append(da)
                     if len(new_voice_list) > 0:
@@ -3587,16 +3595,18 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
                 EventMesh.publish("set_play_new_voice_list",new_voice_list)
                 EventMesh.publish("play_new_voice_list")
         else:#正常留言
-            if EventMesh.publish("get_pwk_cnt_voice") >= 0:
-                for da in voice_list:
-                    new_voice_list.append(da)
-                if len(new_voice_list) > 0:
-                    pass
-                EventMesh.publish("set_play_new_voice_list",new_voice_list)
-                EventMesh.publish("play_new_voice_list")
+            if EventMesh.publish("get_1M_flag") == 0:
+                if EventMesh.publish("get_pwk_cnt_voice") >= 0:
+                    for da in voice_list:
+                        new_voice_list.append(da)
+                    if len(new_voice_list) > 0:
+                        pass
+                    EventMesh.publish("set_play_new_voice_list",new_voice_list)
+                    EventMesh.publish("play_new_voice_list")
     def set_history_board_flag(self,event,msg):
         self.history_board_flag = msg           
-
+    def set_open_device(self,event,msg):
+        self.open_device = msg
 #请求未读的语音消息列表
 class IOTWeb_get_new_voice_msgProtoCol(ProtoCol):
     """get_new_voice_msg"""
@@ -3724,6 +3734,7 @@ class IOTWeb_new_voice_msg_listProtoCol(ProtoCol):
         self.app_new_voice_flag = 0#app是否下发留言
         EventMesh.subscribe("get_app_new_voice_flag",self.get_app_new_voice_flag)
         EventMesh.subscribe("set_app_new_voice_flag",self.set_app_new_voice_flag)
+        EventMesh.subscribe("get_1M_flag",self.get_1M_flag)
     def send(self, event, msg):
         print("send new_voice_msg_list{}".format(msg))
         # 通过websocket发送到服务器端
@@ -3760,7 +3771,9 @@ class IOTWeb_new_voice_msg_listProtoCol(ProtoCol):
         if len(new_voice_list) > 0:
             pass
         EventMesh.publish("set_play_new_voice_list",new_voice_list)
+        print("是否收到留言:{},self._1M_flag = {}".format(EventMesh.publish("get_recv_voice"),self._1M_flag))
         if EventMesh.publish("get_recv_voice") == 0 and self._1M_flag == 0:#当没有音频在播放时,再播放新的,否则保存下来不播放,等60S后一起播放
+            EventMesh.publish("set_recv_voice",1) #设置留言播放状态
             EventMesh.publish("play_new_voice_list")
         else:#当有音频在播放时,存下来开始倒计时
             pass
@@ -3783,15 +3796,18 @@ class IOTWeb_new_voice_msg_listProtoCol(ProtoCol):
             get_VC_satrt_flag = 0
         if get_VC_satrt_flag == 0:
             print("收到多条信息,统一播放")
+            self._1M_flag = 0
             EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S)
             EventMesh.publish("set_history_voice_flag",1)#修改历史留言标志位
             EventMesh.publish("set_wait_voice_flag",1)#修改60S标志位
-            self._1M_flag = 0
             self._1M_timer.stop()
     def get_app_new_voice_flag(self,event,msg):
         return self.app_new_voice_flag
     def set_app_new_voice_flag(self,event,msg):
         self.app_new_voice_flag = msg
+    def get_1M_flag(self,event,msg):
+        return self._1M_flag  
+        
 class IOTWeb_put_voice_msg_stateProtoCol(ProtoCol):
     """put_voice_msg_state"""
     TYPE = "put_voice_msg_state"