修改了60S后播放留言不连贯,是一条条播的bug
authorazao <821478748@qq.com>
Tue, 9 Dec 2025 08:13:54 +0000 (16:13 +0800)
committerazao <821478748@qq.com>
Tue, 9 Dec 2025 08:46:48 +0000 (16:46 +0800)
并且把未读留言保存本地,重启时能够查看留言标志位

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/ai_alarm.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py

index 28248df..5e9bdae 100644 (file)
@@ -2932,6 +2932,9 @@ class AI_VC(Abstract):
         self.stop_voice_timer=osTimer()
         self.pwk_cnt_voice = 0 #不听语音后,积攒的次数,需要一起播放
         self.pwk_notice_flag = 0#是否处于积攒留言状态(用来实现单次提醒)
+        self.is_noread_voice = EventMesh.publish("get_storage_config","is_noread_voice")
+        if self.is_noread_voice == None:
+            self.is_noread_voice = 0#是否还有未读留言(开机判断)
         EventMesh.subscribe("AI_key_press", self.AI_key_press)
         EventMesh.subscribe("BT_AI_key_press", self.BT_AI_key_press)
         EventMesh.subscribe("stop_AI_record", self.stop_AI_record)
@@ -2966,6 +2969,7 @@ class AI_VC(Abstract):
         EventMesh.subscribe("get_wait_voice_flag",self.get_wait_voice_flag)#获取60S等待留言播放定时器状态
         EventMesh.subscribe("set_wait_voice_flag",self.set_wait_voice_flag)#修改60S等待留言播放定时器状态
         EventMesh.subscribe("rate_move",self.rate_move)#NLP修改语速
+        EventMesh.subscribe("set_pwk_notice_flag",self.set_pwk_notice_flag)#设置未读状态
         # EventMesh.subscribe("get_voicerupt_flag",self.get_voicerupt_flag)#获取留言播放状态
         # EventMesh.subscribe("chenggong_tone",self.chenggong_tone)
         
@@ -3046,7 +3050,8 @@ class AI_VC(Abstract):
                 self.speech_rate -= 10
         EventMesh.publish("set_storage_config",["speech_rate",self.speech_rate])
         print("set_speech_rate:{}".format(self.speech_rate))
-
+    def set_pwk_notice_flag(self,event,msg):#设置未读状态
+        self.pwk_notice_flag =  msg
     #获取60S等待留言播放定时器状态
     def get_wait_voice_flag(self,event,msg):
         return self.wait_voice_flag
@@ -3218,6 +3223,7 @@ class AI_VC(Abstract):
 
     def set_pwk_cnt_voice(self, event=None, msg = None):
         self.pwk_cnt_voice=msg
+        print("设置未读次数为:{}".format(self.pwk_cnt_voice))
 
     #会议
     def get_meetaudio_flag(self, event=None, msg = None):
@@ -3477,8 +3483,9 @@ 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#退出留言以及留言查看
+        if EventMesh.publish("get_recv_voice") == 1:
+            EventMesh.publish("update_play_new_voice_info")#更新已读状态
+            self.recv_voice = 0#退出留言以及留言查看
         EventMesh.publish("set_history_voice_flag",0)#修改标志位
         self.AI_new_voice_url = ""
         EventMesh.publish("publish_AI_btnInfo",{"func":self.Close}) 
@@ -4322,6 +4329,7 @@ class AI_VC(Abstract):
                                 self.pwk_notice_flag = 0
                                 self.wait_first_flag = 0#让下次未读播放提示恢复
                                 self.voice_notice = 1#开启回复
+                                EventMesh.publish("set_storage_config",["is_noread_voice",0])
                             if self.voice_choose_flag == 1:#播放完语音后,有冲突的时候关闭
                                 self.voice_choose_flag = 0
                                 self.Close_flag = 1
@@ -5810,6 +5818,7 @@ class AI_VC(Abstract):
                 #     EventMesh.publish("play_tts",["您有一条语音留言,10秒内按下中间键可以收听",1])
                 if self.pwk_notice_flag == 0 and EventMesh.publish("get_app_new_voice_flag"):#不处于播放状态并且是小程序下发的语音而不是请求的
                     self.pwk_cnt_voice += 1#加上当前这条
+                    EventMesh.publish("set_storage_config",["is_noread_voice",1])
                     EventMesh.publish("set_app_new_voice_flag",0)
                     print("voice_add_to = {}".format(self.pwk_cnt_voice))
                 print("self.pwk_notice_flag = {}".format(self.pwk_notice_flag))
index af7176a..bdde6c9 100644 (file)
@@ -955,8 +955,8 @@ class schedule(Abstract):
                 name = alarm_tts_info["title"]
                 if AringTimes == 0:
                     AringTimes = 1
-                repeat_sentence = (alarm_TTS_str + ",")  # 重复5次并加逗号分隔
-                final_sentence = repeat_sentence.rstrip(",")
+                repeat_sentence = name  # 重复5次并加逗号分隔
+                final_sentence = repeat_sentence
                 final_sentence = "日程提醒: 您设置的" + final_sentence + "时间到了,请留意"
                 self.schedule_play_count = AringTimes
                 EventMesh.publish("play_tts",[final_sentence,1])  #播放tts闹钟文本内容
index e413945..0d739ff 100644 (file)
@@ -1605,6 +1605,10 @@ class SockMangager(Abstract):
                     print("结束播放")
                     self.stop_play = 0
                     break
+                if EventMesh.publish("get_storage_config","is_noread_voice") == 1:#还有未读的(开机)
+                    if EventMesh.publish("get_open_device") == 1:#刚开机
+                        EventMesh.publish("play_wait_voice",[url,1])
+                        EventMesh.publish("set_open_device",0)
                 if EventMesh.publish("get_history_voice_flag") == 1:#播放历史留言 or 播放当前留言
                     if EventMesh.publish("get_wait_voice_flag") == 1:#等待留言
                         EventMesh.publish("play_wait_voice",[url,1])
@@ -2705,7 +2709,8 @@ def ai_cmd_handle(cmd):
     elif "查看历史留言" in cmd :#当指令中有查看历史留言时,调用历史留言接口
         EventMesh.publish(WEB_CMD_ENUM.GET_NEW_VOICE_MSG_S)
         EventMesh.publish("set_history_voice_flag",1)#修改标志位
-        EventMesh.publish("clean_unread_vocie")#清空未读多条一起下发记录    
+        EventMesh.publish("clean_unread_vocie")#清空未读多条一起下发记录   
+        EventMesh.publish("set_storage_config",["is_noread_voice",0])
         pass
     elif "语速倍速设置为:" in cmd:#修改对话模式
         voice_start_index = cmd.index("语速倍速设置为:") + len("语速倍速设置为:")#动态判断截取部分
@@ -3540,6 +3545,7 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
         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)
+        EventMesh.subscribe("get_open_device",self.get_open_device)
     def send(self, event, msg):
 
         print("send find_voice_msg_list")
@@ -3557,8 +3563,6 @@ 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 = "历史未读留言列表为空"
@@ -3572,6 +3576,9 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
                 else:#等待历史留言
                     self.has_processed_wait_voice = 0
                     self.wait_first_flag = 0
+                EventMesh.publish("set_recv_voice",0) #设置留言播放状态
+                EventMesh.publish("set_history_voice_flag",0)
+                EventMesh.publish("set_wait_voice_flag",0)
             else:#有历史留言
                 if EventMesh.publish("get_wait_voice_flag") == 0:#历史留言
                     print("历史广播状态!!!!! = {}".format(self.history_board_flag))
@@ -3587,7 +3594,6 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
                 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:
@@ -3607,6 +3613,8 @@ class IOTWeb_find_new_voice_msgProtoCol(ProtoCol):
         self.history_board_flag = msg           
     def set_open_device(self,event,msg):
         self.open_device = msg
+    def get_open_device(self,event,msg):
+        return self.open_device
 #请求未读的语音消息列表
 class IOTWeb_get_new_voice_msgProtoCol(ProtoCol):
     """get_new_voice_msg"""
@@ -3797,6 +3805,7 @@ class IOTWeb_new_voice_msg_listProtoCol(ProtoCol):
         if get_VC_satrt_flag == 0:
             print("收到多条信息,统一播放")
             self._1M_flag = 0
+            EventMesh.publish("set_pwk_cnt_voice",len(EventMesh.publish("get_play_new_voice_list")))#设置未读次数
             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标志位