From: azao <821478748@qq.com> Date: Mon, 10 Nov 2025 09:41:38 +0000 (+0800) Subject: 修改留言时出现的bug X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=a791ebda9b8d64f7df1b7bc7199e01a4410b5613;p=mirrors%2FASR1603_G5.git 修改留言时出现的bug 添加NLP日程的框架(有待修改) --- diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py index bc85cba6..ed331dfb 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py @@ -3219,6 +3219,8 @@ class AI_VC(Abstract): self.stop_voice_timer.stop() #关闭语音留言模式定时器 # EventMesh.publish("stop_AI_record") self.Close() + self.revoice_cnt = 0 + self.revoice_timer.stop()#回复定时器关闭,计数器清零 EventMesh.publish("open_led_green") EventMesh.publish("start_voice_record",2)#开始语音录音 return @@ -3365,6 +3367,7 @@ class AI_VC(Abstract): EventMesh.publish("close_led") EventMesh.publish("stop_voice_record")#停止静默录音 tts_play_str = "留言已发送" + self.voice_flag=0 EventMesh.publish("play_tts",[tts_play_str,1]) return if self.AI_key_long_press_flag == 1 :#有长按 diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py index e888e78b..54360d21 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py @@ -847,6 +847,7 @@ class schedule(Abstract): EventMesh.subscribe("AI_schedule_open",self.AI_schedule_open)# EventMesh.subscribe("set_schedule_info",self.set_schedule_info)# EventMesh.subscribe("clear_shcheude_flag",self.clear_shcheude_flag) + EventMesh.subscribe("GET_NEED_SCHEDULE_REPORT_INFO",self.get_need_schedule_report_info)#上传日程数组 self.schedule_play_timer = osTimer() self.timer_flag = 0#定时器开启状态 self.schedul_timer_default = 60*5 #默认5分钟提醒一次日程 @@ -865,6 +866,7 @@ class schedule(Abstract): "descrip" : descrip#播报内容 } print("已添加日程 {},将提醒 {} 次(间隔5分钟)".format(schedule_id,remind_times)) + EventMesh.publish("GET_NEED_SCHEDULE_REPORT_INFO") return schedule_id def set_schedule_info(self,event=None,msg=None): @@ -930,14 +932,16 @@ class schedule(Abstract): if year_now != date_year or (year_now == date_year and month_now > date_month) or (year_now == date_year and month_now == date_month and day_now >date_day): #当前年份大于设置的年份清除这个 print("当前年份大于设置的年份") self.schedule_array.pop(i) - EventMesh.publish("set_storage_config",["schedule",self.schedule_array])#读取闹钟数组 + EventMesh.publish("set_storage_config",["schedule",self.schedule_array])#读取日程数组 + EventMesh.publish("GET_NEED_SCHEDULE_REPORT_INFO") continue if (year_now == date_year and month_now == date_month and date_day == day_now): if hour_now*60 + minute_now > set_hour*60 +set_min: #年月日相等 时间分钟大于设置分钟数不再检查当前index了 print("时间过了") self.schedule_array.pop(i) - EventMesh.publish("set_storage_config",["schedule",self.schedule_array])#读取闹钟数组 + EventMesh.publish("set_storage_config",["schedule",self.schedule_array])#读取日程数组 + EventMesh.publish("GET_NEED_SCHEDULE_REPORT_INFO") continue if year_now == date_year and month_now == date_month and date_day == day_now and set_hour == hour_now and set_min == minute_now: #该提醒了 @@ -966,7 +970,6 @@ class schedule(Abstract): if self.timer_flag == 0: self.schedule_play_timer.start(self.schedul_timer_default*1000,1,self.shchedu_play_repeat_timer) self.timer_flag = 1 - print("日程:{} self.schedule_array :{}".format(final_sentence,self.schedule_array)) #循环播放定时器 def clear_shcheude_flag(self,event = None,msg = None): @@ -1008,7 +1011,101 @@ class schedule(Abstract): self.schedule_play_timer.stop() self.timer_flag = 0 print("字典为空,清除定时器") + def get_need_schedule_report_info(self,event=None,Num=None):#上报日程 + print("上报日程协议->IOT平台") + schedule_list = [] + date_tmp = utime.localtime() + time_tmp = utime.mktime(date_tmp) + if len(self.schedule_array) > 0: + for _schedule in self.schedule_array: + schedule_info = {} + if len(_schedule["name"]) == 0: + _schedule["name"] = "闹钟" + + schedule_info["name"] = _schedule["name"] + schedule_info["loop"] = _schedule["loop"] + schedule_info["state"] = _schedule["state"] + schedule_info["time"] = _schedule["time"] + schedule_info["ringTimes"] = _schedule["ringTimes"] + schedule_info["scheduleMode"] = _schedule["scheduleMode"] + schedule_info["shakeType"] = _schedule["shakeType"] + schedule_list.append(schedule_info) + schedule_send = { + "cmd":"post_schedule", + "ts":time_tmp, + "msg":"上报日程", + "data":schedule_list + } + EventMesh.publish("REPORT_SCHEDULE_TO_IOT",schedule_send) + return schedule_send + def read_schedule_list(self,event=None,Num=None):#读日程全列表 + schedulelist_TTS_str =""#日程全列表播放tts字符串 + if len(self.schedule_array) == 0: + schedulelist_TTS_str = "当前日程列表没有闹钟信息" + EventMesh.publish("play_tts",[schedulelist_TTS_str,1]) + return + + time_tuple = utime.localtime()#获取当前日期&时间的元组 + year_now = time_tuple[0] + month_now = time_tuple[1] + day_now = time_tuple[2] + hour_now = time_tuple[3] + minute_now = time_tuple[4] + schedulelist_TTS_str += "当前日程信息如下:" + for i,_schedule in enumerate(self.schedule_array): + if "interval" in _schedule :#间隔提醒日程 + continue + + state = schedule["state"] + loop = _schedule["loop"] + descrp = _schedule["name"] + set_hour = int((_schedule["time"]).split(":")[0]) + set_min = int((_schedule["time"]).split(":")[1]) + + week = "" + final_sentence = "" + for n,we in enumerate(loop): + week_t = n + if we == "1": + if n == 0: + week_t = 7 + final_sentence+=self.get_week_str(week_t)+"," + print("final_sentence = {}".format(final_sentence)) + week = final_sentence.rstrip(",") + if len(week) != 0: + schedulelist_TTS_str += "日程{},{},{}点{}分提醒您:{}。".format(i+1,week,set_hour,set_min,descrp) + else: + schedulelist_TTS_str += "日程{},{}点{}分提醒您:{}。".format(i+1,set_hour,set_min,descrp) + pass + print("self.schedulelist_TTS_str = {}".format(schedulelist_TTS_str)) + EventMesh.publish("play_tts",[schedulelist_TTS_str,1]) + def AI_delete_schedule(self,event=None,Num=None):#删除日程 + self.schedule_array =[]#日程队列清空 + clear_ttr = "日程列表已清空" + date_tmp = utime.localtime() + time_tmp = utime.mktime(date_tmp) + try: + EventMesh.publish("set_storage_config",["schedule_list",self.schedule_array]) + schedule_send = { + "cmd":"post_schedule", + "ts":time_tmp, + "msg":"上报日程", + "data":self.schedule_array + } + EventMesh.publish("REPORT_schedule_TO_IOT",schedule_send) + except Exception as e: + usys.print_exception(e) + clear_ttr = "清除日程列表失败" + return clear_ttr + def delete_single_schedule(self,event=None,Num=None): #删除单个日程 + if len(self.schedule_array) == 0: + return + if len(self.schedule_array) >= Num: #只有大于等于列表个数才能删除对应日程信息 + self.schedule_array.pop(Num) + EventMesh.publish("set_storage_config",["schedule_list",self.schedule_array]) + EventMesh.publish("get_need_schedule_report_info") + pass diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/main_init.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/main_init.py index cab3d7f2..4c0c1dcd 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/main_init.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/main_init.py @@ -214,11 +214,13 @@ def main_init(): pcr.add_support(pro.IOTWeb_post_sosProtoCol()) pcr.add_support(pro.IOTWeb_post_device_stateProtoCol()) pcr.add_support(pro.IOTWeb_post_alarmProtoCol()) + pcr.add_support(pro.IOTWeb_post_scheduleProtoCol()) pcr.add_support(pro.IOTWeb_post_locationProtoCol()) pcr.add_support(pro.IOTWeb_locatedurationProtoCol()) pcr.add_support(pro.IOTWeb_FindDeviceProtoCol()) # pcr.add_support(pro.IOTWeb_alarm_configProtoCol()) pcr.add_support(pro.IOTWeb_alarm_listProtoCol()) + pcr.add_support(pro.IOTWeb_schedule_listProtoCol()) pcr.add_support(pro.IOTWeb_sos_listProtoCol()) pcr.add_support(pro.IOTWeb_volumeProtoCol()) pcr.add_support(pro.IOTWeb_sos_configProtoCol()) diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py index 4d535c98..fbf598a4 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/protocol.py @@ -574,6 +574,8 @@ class WEB_CMD_ENUM: POST_ALARM_R_CMD = "post_alarm_R" POST_ALARM_S_CMD = "post_alarm_S" + POST_SCHEDULE_R_CMD = "post_schedule_R" + POST_SCHEDULE_S_CMD = "post_schedule_S" FIND_DEVCE_R_CMD = "find_device_R" FIND_DEVCE_S_CMD = "find_device_S" @@ -590,6 +592,9 @@ class WEB_CMD_ENUM: ALARM_LIST_R_CMD = "alarm_list_R" ALARM_LIST_S_CMD = "alarm_list_S" + SCHEDULE_LIST_R_CMD = "schedule_list_R" + SCHEDULE_LIST_S_CMD = "schedule_list_S" + SOS_LIST_R_CMD ="sos_list_R" SOS_LIST_S_CMD ="sos_list_S" @@ -712,6 +717,8 @@ class IOTSendCmdManager(Abstract): return self.send_data elif msg == WEB_CMD_ENUM.POST_ALARM_S_CMD: self.send_data = self.alarm_config_send_data() + elif msg == WEB_CMD_ENUM.POST_SCHEDULE_S_CMD: + self.send_data = self.schedule_config_send_data() return self.send_data # 心率上报数据格式 @@ -831,6 +838,35 @@ class IOTSendCmdManager(Abstract): } return alarm_data + #日程配置上报数据格式 + def schedule_config_send_data(self): + schedule_data = { + "cmd":"post_schedule", + "ts":self.time_tmp, + "msg":"上报日程", + "data":[ + { + "name":"喝水", + "loop":"0101001", + "state":"0", + "time":"14:34", + "ringTimes":1, + "alarmMode":"ring", + "shakeType":"short" + }, + { + "name":"起床", + "loop":"0101001", + "state":"0", + "time":"07:40", + "ringTimes":1, + "alarmMode":"ring", + "shakeType":"short" + } + ] + } + + return schedule_data #解析收到的数据协议 def playpolad_data(data): if(isinstance(data, bytes) == 0 or len(data) <= PROTOCLO_LEN): @@ -1324,10 +1360,14 @@ class SockMangager(Abstract): self.locate_duration_state = self.location_info["state"] #是否开启频率定位 pass EventMesh.subscribe("REPORT_ALARM_TO_IOT",self.report_alarm_to_iot) + EventMesh.subscribe("REPORT_SCHEDULE_TO_IOT",self.report_schedule_to_iot) def report_alarm_to_iot(self,event,msg): EventMesh.publish(WEB_CMD_ENUM.POST_ALARM_S_CMD,msg) pass + def report_schedule_to_iot(self,event,msg): + EventMesh.publish(WEB_CMD_ENUM.POST_SCHEDULE_S_CMD,msg) + pass def usb_event_cb(self, state): status = state def post_processor_after_instantiation(self): @@ -3264,6 +3304,103 @@ class IOTWeb_get_chat_configProtoCol(ProtoCol): @param msg: 接收到的下行数据 """ print("recv get_chat_config{}".format(msg)) + +#上报日程列表 +class IOTWeb_post_scheduleProtoCol(ProtoCol): + """post_schedule""" + TYPE = "post_schedule" + + def send(self, event, msg): + print("send post_schedule{}".format(msg)) + # 通过websocket发送到服务器端 + + send_data = b'' + send_data = protocol_send_total_data(msg) + print("send send_data{}".format(send_data)) + EventMesh.publish("CHANNEL_IOT_WEB_SEND",send_data) + + def recv(self, event, msg): + """ + + @param event:post_schedule + @param msg: 接收到的下行数据 + """ + print("recv post_schedule{}".format(msg)) + +#日程列表(NLP识别下发) +class IOTWeb_schedule_listProtoCol(ProtoCol): + """schedule_list""" + TYPE = "schedule_list" + + def send(self, event, msg): + print("send schedule_list {}".format(msg)) + # 通过websocket发送到服务器端 + date_tmp = utime.localtime() + time_tmp = utime.mktime(date_tmp) + rest = "error" + if msg == 1: + rest = "success" + schedule_list ={ + "cmd":"dispatch_rest", + "ts":time_tmp, + "msg":"消息收到响应", + "data":{ + "cmd":"schedule_list", + "rest":rest, + "msg":"日程配置成功." + } + } + send_data = b'' + send_data = protocol_send_total_data(schedule_list) + print("send_data schedule_list {}".format(msg)) + EventMesh.publish("CHANNEL_IOT_WEB_SEND", send_data) + + def recv(self, event, msg): + """ + + @param event:上行下发闹钟配置 + @param msg: 接收到的下行数据 + """ + # 定义要添加的新元素 + # new_item = {'time': '11:30','index': 1} + # data = [{"index":1,"name":"hihihi1"},{"index":2,"name":"hihihi2"},{"index":0,"name":"hihihi0"}] + # len_t = len(data) + # j = 0 + # for i in range(len_t): + # if data[j]['index'] == 1: + # removed_item = data.pop(j) + # print(data) + # j=0 + # continue + # j+=1 + # len_t = len(data) + # print(len_t) + # for i in range(len(data)): + # data[i]["index"] = i + + # url = http://220.160.104.34:30800/ws-bus/test/voice-record/876226211472149?state=1 + # url = http://220.160.104.34:30800/ws-bus/test/876226211472149?testType = alarmList + + schedule_list=[] + ret = 1 + if "data" in msg: + data = msg["data"] + if isinstance(data,list) == True: + for i in range(len(data)): + data_list = data[i] + data_list["index"] = i + print("schedule_list:{}".format(data_list)) + schedule_list.append(data_list) + schedule_list.sort(key=lambda x: x['index']) + EventMesh.publish("set_storage_config",["schedule_list",schedule_list]) + EventMesh.publish("set_schedule_info",schedule_list) + schedule_list = EventMesh.publish("get_storage_config","alarm_list") + print("schedule_list:{}".format(schedule_list)) + else: + ret = 0 + + EventMesh.publish(WEB_CMD_ENUM.SCHEDULE_LIST_S_CMD,ret) + #下发日程 class IOTWeb_scheduleProtoCol(ProtoCol): """schedule"""