From: dxy15521469561 <1731678236@qq.com> Date: Tue, 26 Sep 2023 02:27:57 +0000 (+0800) Subject: D10: X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=a73df52a2239e50f409f9b498b6ad630e21d657a;p=mirrors%2FASR1603_G5.git D10: 更新还原最新版本BTN --- diff --git a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py index d8b574e2..7641ede3 100644 --- a/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py +++ b/2.sdk/project/D10/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py @@ -39,8 +39,11 @@ class intervManager(Abstract): def __init__(self): self.timer = osTimer() - self.pwk_timer = osTimer() + self.pwk_timer1 = osTimer() + self.pwk_timer2 = osTimer() self.timer1 = osTimer() + self.timer1_sos = osTimer() + self.sos_timer1 = osTimer() self.aud = audio.Audio(0) self.aud.set_pa(Pin.GPIO29) self.aud.setVolume(11) @@ -100,6 +103,7 @@ class intervManager(Abstract): self.read_data = {} self.volum_size = 8 self.phone_num = '' + self.sos_phone_num = '' self.msg_tmp = "" self.time_count = 0 check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat_record.json") @@ -155,6 +159,7 @@ class intervManager(Abstract): EventMesh.subscribe("call_test_event", self.call_test_event)#电话拨进响铃测试 EventMesh.subscribe("dial_out_call_center_cb", self.dial_out_call_center_cb)#电话拨出去 + EventMesh.subscribe("sos_out_call_center_cb", self.sos_out_call_center_cb)#sos拨打 EventMesh.subscribe("close_audio_play", self.close_audio_play)#关闭音频 @@ -181,6 +186,18 @@ class intervManager(Abstract): EventMesh.subscribe("recv_wechat_audio", self.recv_wechat_audio)# + + EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件 + + + def sos_short_press(self,args,msg): + EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话 + EventMesh.publish("close_audio_play")#强制关闭音频文件播放 + EventMesh.publish("STOP_FIND_WATCH")#停止查找设备 + EventMesh.publish("STOP_ALARM_RING")#停止闹钟响铃 + EventMesh.publish("play_cur_time_event")#播报当前时间 + #播报当前时间 + def recv_wechat_audio(self,event,str_data):#接收微聊语音播放 if self.press_btn == 0: str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_WECHAT_RECV")) @@ -191,12 +208,12 @@ class intervManager(Abstract): def audio_event_queue_thread(self): while True: data = self.audio_event_queue.get() - #print("interInfo_queue_thread:data = {}".format(data)) + #print("audio_event_queue:data = {}".format(data)) if data != None: try: data["func"](data["data"]) except Exception as e: - print("interInfo_queue_thread:ERROR:{}".format(e)) + print("audio_event_queue:ERROR:{}".format(e)) usys.print_exception(e) def publish_message_event_audio(self,event,msg): self.audio_event_queue.put(msg) @@ -208,13 +225,14 @@ class intervManager(Abstract): def play_audio_file_do(self,data):#msg 拼接的路径文件 open_power = EventMesh.publish("get_power_on_state")#获取开机标识 power_off = EventMesh.publish("get_power_off_state")#获取开机标识 + print("play_audio_file",data[0],data[1],open_power,power_off)#路径 str_data[1] 是否需要被打断 if open_power != None: if open_power == 0: return if power_off != None: if power_off == 1: return - print("play_audio_file",data[0],data[1])#路径 str_data[1] 是否需要被打断 + print("play_audio_file end",data[0],data[1])#路径 str_data[1] 是否需要被打断 self.aud.montage_play('U:/static/audio.bin',1,data[1],data[0]) @@ -250,12 +268,12 @@ class intervManager(Abstract): EventMesh.publish("publish_message_event_interInfo",{"func":self.Alarm_timer_cb,"data":0}) def powe_resatrt_down_fun(self, *args): - EventMesh.publish("close_all_led")#关闭所有的灯 + EventMesh.publish("close_led_pin") self.aud.stopPlayStream() Power.powerRestart() def power_down_fun(self, *args): - EventMesh.publish("close_all_led")#关闭所有的灯 + EventMesh.publish("close_led_pin") self.aud.stopPlayStream() Power.powerDown() @@ -275,7 +293,7 @@ class intervManager(Abstract): def close_timer_all(self, event, msg): - self.timer.stop() + print("close_timer_all!!!!!!!!!!!!!!!!!!!") open_power = EventMesh.publish("get_power_on_state")#获取开机标识 power_off = EventMesh.publish("get_power_off_state")#获取开机标识 if open_power != None: @@ -286,6 +304,8 @@ class intervManager(Abstract): return self.aud.stopPlayStream() + self.timer.stop() + def answer_call_event(self, event, msg): # @@ -355,10 +375,39 @@ class intervManager(Abstract): self.timer1.start(2000, 0, self.time_out_phone) str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件 + + def sos_out_call_center_cb(self, event, msg):#sos电话呼叫中 + open_power = EventMesh.publish("get_power_on_state")#获取开机标识 + if open_power != None: + if open_power == 0: + return + power_off = EventMesh.publish("get_power_off_state")#获取开机标识 + if power_off != None: + if power_off == 1: + return + self.sos_phone_num = '' + print("sos_out_call_center_cb",msg) + if self.call_state == 0: + EventMesh.publish("close_timer_all")# + if msg == None: + str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL")) + EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件 + # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data) + else: + self.sos_phone_num = msg + self.sos_timer1.start(2000, 0, self.sos_call_out_phone) + self.timer1_sos.start(30000, 0, self.sos_time_out_phone) + str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT")) + EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件 + def sos_time_out_phone(self, msg):#30s超时未打通或者信号不好则重新拨打 + sos_flag = EventMesh.publish("get_sos_flag") + if sos_flag == 1: + if self.call_state == 0: + EventMesh.publish("set_sos_info_call") - def time_out_phone(self, msg):#电话拨出去 - voiceCall.callStart(self.phone_num) + def sos_call_out_phone(self, msg):#电话拨出去 + voiceCall.callStart(self.sos_phone_num) def call_test_event(self, event, msg): @@ -632,37 +681,38 @@ class intervManager(Abstract): if msg == 1: self.usbState = msg - + str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE] + EventMesh.publish("set_led_time_arg",str_buf)# if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断 EventMesh.publish("close_timer_all")# str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_IN")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - - EventMesh.publish("set_led_time_arg",None)# print("charge R_CHARGE_IN") elif msg == 2: self.usbState = msg + EventMesh.publish("stop_led_timer")#设置参数 + # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功 + EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功 print("charge R_CHARGE_OUT") if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断 EventMesh.publish("close_timer_all")# str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_OUT")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - EventMesh.publish("stop_led_timer")#设置参数 - # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功 - EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功 + elif msg == 3: self.usbState = msg print("charge full") - + str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE] + EventMesh.publish("set_led_time_arg",str_buf)# if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断 EventMesh.publish("close_timer_all")# str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_FULL")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - EventMesh.publish("set_led_time_arg",None)# + def get_usb(self, event, msg): @@ -671,13 +721,11 @@ class intervManager(Abstract): def open_power_on(self, event, msg): #msg 1 开机 2 关机 3 重启 4恢复出厂设置 EventMesh.publish("close_timer_all")# if msg == 1: - self.power_on_flag = 1 - str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1")) - EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功 - # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数 - self.power_on_flag = 0 - self.pwk_timer.start(5000,0,self.power_on_cb) + + # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1")) + # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) + self.pwk_timer1.start(3000,0,self.power_on_audio_cb) + elif msg == 2: flag = EventMesh.publish("get_call_state") if flag != 0:#电话呼叫中 @@ -689,20 +737,16 @@ class intervManager(Abstract): date_tmp = utime.localtime() time_tmp = utime.mktime(date_tmp) EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间 - str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1")) - EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_RED,4,2,led_mode.OTHER_MEASURE_MODE])# - self.power_off = 1 - # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])# - self.timer.start(6000,0,self.publish_power_down_event_cb) + self.pwk_timer1.start(3000,0,self.power_off_audio_cb) elif msg == 3: flag = EventMesh.publish("get_call_state") if flag != 0:#电话呼叫中 voiceCall.callEnd() - str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1")) - EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - # EventMesh.publish("stop_led_timer")#设置参数 + self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3') + # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1")) + # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) + EventMesh.publish("stop_led_timer")#设置参数 self.power_off = 1 self.timer.start(8000,0,self.publish_resatrt_down_event_cb) #EventMesh.publish("set_led_time_arg",[3000,4000,1,led_mode.LONG_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE])# @@ -729,17 +773,44 @@ class intervManager(Abstract): def power_on_cb(self, msg): #msg 开机标识 self.power_on_flag = 1 + def clear_power_on_cb(self, msg): #msg 开机标识 + self.power_on_flag = 0 + def power_on_audio_cb(self, msg): + self.power_on_flag = 1 + print("power_on_audio_cb") + self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3') + # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1")) + # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) + EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功 + # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数 + self.pwk_timer1.start(2000,0,self.clear_power_on_cb) + self.pwk_timer2.start(6000,0,self.power_on_cb) + def get_power_on_state(self, event, msg): return self.power_on_flag + def power_off_audio_cb(self, msg): + print("power_off_audio_cb") + self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3') + # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1")) + # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) + EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_RED,4,2,led_mode.POWER_OFF_MODE])# + + self.pwk_timer1.start(2000,0,self.set_power_off_cb) + self.pwk_timer2.start(7000,0,self.publish_power_down_event_cb) + + def set_power_off_cb(self, msg): + self.power_off = 1 + def get_power_off_state(self, event, msg): return self.power_off - def close_hr_sop2(self, event, msg): #msg 关闭心率血氧测试 + def close_hr_sop2(self, event, msg): #msg 关闭心率血氧体温测试 get_hr_state = EventMesh.publish("get_hr_state") get_spo2_state = EventMesh.publish("get_spo2_state") - if get_hr_state != None and get_spo2_state != None: + get_temp_state = EventMesh.publish("get_temp_state") + if get_hr_state != None or get_spo2_state != None or get_temp_state != None: if get_hr_state != 0: EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 print("sstop hr") @@ -748,6 +819,10 @@ class intervManager(Abstract): print("stop spo2") EventMesh.publish("set_spo2_state",0)#2代表后台进入测试 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) + if get_temp_state != 0: + print("stop temp") + EventMesh.publish("set_temp_state",0) + EventMesh.publish(constants.EVENT.STOP_TEMP)#手动体温测试 def set_manual_measure_mode(self, event, msg): #手动测试 1心率 2 血氧 3 体温 get_hr_state = EventMesh.publish("get_hr_state") @@ -969,6 +1044,7 @@ class intervManager(Abstract): flag = EventMesh.publish("get_call_state") if flag != 2:#电话通话中 或者呼叫中挂断中断 EventMesh.publish("close_timer_all")# + # EventMesh.publish("stop_led_timer")#设置参数 mode = 0 signal = EventMesh.publish("screen_get_sig") if signal != None: @@ -980,23 +1056,21 @@ class intervManager(Abstract): else:#未插卡 mode = 3 if mode == 1:#白色灯 - EventMesh.publish("set_led_time_arg",[1,1,6,led_mode.FLASH_LIGHT_WHITE,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功 + EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_WHITE,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功 # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_WHITE,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) pass elif mode == 2:#蓝灯色灯 - EventMesh.publish("set_led_time_arg",[1,1,6,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功 + EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_GREEN,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功 # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_CONNECT")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) pass elif mode == 3:#红灯闪烁 + EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - EventMesh.publish("set_led_time_arg",[1,1,6,led_mode.FLASH_LIGHT_RED,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功 - # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数 - pass pass def dial_sos_phone(self, event, msg): #拨打紧急求助电话 @@ -1011,13 +1085,13 @@ class intervManager(Abstract): if sos_number != None: if len(sos_number) != 0: EventMesh.publish("close_timer_all")# - EventMesh.publish("save_phonename",sos_number[0]) - EventMesh.publish("save_phonenum",sos_number[0]) - EventMesh.publish("set_sos_num",0) + # EventMesh.publish("save_phonename",sos_number[0]) + # EventMesh.publish("save_phonenum",sos_number[0]) + # EventMesh.publish("set_sos_num",0) EventMesh.publish("set_sos_flag",1) - str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT")) - EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件 - voiceCall.callStart(sos_number[0]) + # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT")) + # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件 + # voiceCall.callStart(sos_number[0]) else:#未设置sos紧急求助号码 EventMesh.publish("close_timer_all")# str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL")) @@ -1031,7 +1105,11 @@ class intervManager(Abstract): EventMesh.publish("close_timer_all")# str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM")) EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data) - + + + + + def send_find_watch(self, event, msg): #发送查找设备指令 open_power = EventMesh.publish("get_power_on_state")#获取开机标识 if open_power != None: @@ -1098,6 +1176,7 @@ class intervManager(Abstract): if self.alarm_state == 1: self.alarm_state = 0 self.alarm_timer_count = 0 + # EventMesh.publish("stop_led_timer")#设置参数 self.aud.stopPlayStream() #停止播放 self.timer.stop() @@ -1511,7 +1590,7 @@ class intervManager(Abstract): time_tmp = utime.mktime(date_tmp) if state != None: if state == 1: - EventMesh.publish("set_led_time_arg",[1,1,4,led_mode.FLASH_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功 + EventMesh.publish("set_led_time_arg",[1,2,8,led_mode.FLASH_LIGHT_GREEN,8,4,led_mode.OTHER_MEASURE_MODE])#測量成功 # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数 if self.updateTime == 0: self.updateTime = time_tmp @@ -1586,6 +1665,9 @@ class BtnDevice(Abstract): self.btnInfo_queue = Queue() _thread.start_new_thread(self.btnInfo_queue_thread, ()) EventMesh.subscribe("publish_message_event_btnInfo",self.publish_message_event_btnInfo) + + EventMesh.subscribe("close_wechat_btn_timer", self.close_wechat_btn_timer)#来电强制关闭微聊语音 + def btnInfo_queue_thread(self): while True: data = self.btnInfo_queue.get() @@ -1614,8 +1696,7 @@ class BtnDevice(Abstract): def post_processor_after_instantiation(self): # self.keypad.init() # self.keypad.set_callback(self.key_callback) - EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件 - EventMesh.subscribe("close_wechat_btn_timer", self.close_wechat_btn_timer)#来电强制关闭微聊语音 + self.pk.powerKeyEventRegister(self.powerKey_callback) self.extint = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb) @@ -1629,16 +1710,6 @@ class BtnDevice(Abstract): key19 = Pin(Pin.GPIO19, Pin.OUT, Pin.PULL_PU, 0) - def sos_short_press(self,args,msg): - EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话 - EventMesh.publish("close_audio_play")#强制关闭音频文件播放 - EventMesh.publish("stop_led_timer")#设置参数关闭定时器 同时也关闭所有的灯再开相对应的灯 - EventMesh.publish("STOP_FIND_WATCH")#停止查找设备 - EventMesh.publish("STOP_ALARM_RING")#停止闹钟响铃 - EventMesh.publish("play_cur_time_event")#播报当前时间 - #播报当前时间 - - def pwk_extint_cb(self,args):#侧边按键 self.GPIO26_status = self.extint.read_level() print('### key20_extint_cb {} self.GPIO26_status :{}'.format(args,self.GPIO26_status)) # args[0]:gpio号 args[1]:上升沿或下降沿 @@ -1696,7 +1767,8 @@ class BtnDevice(Abstract): EventMesh.publish("publish_message_event_btnInfo",{"func":self.pwKey_timeout_cb,"data":0}) def pwKey_timeout_cb(self, data):#侧边按键 - if self.pwKey_press_count >= 1: + if self.pwKey_press_count == 1: + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("dialing_out_event")#电话呼叫中voiceCall.callEnd() self.pwKey_press_count = 0 # EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位 @@ -1709,7 +1781,7 @@ class BtnDevice(Abstract): EventMesh.publish("close_hr_sop2")# flag = EventMesh.publish("get_call_state") if flag != 1: - EventMesh.publish("set_sim_mode")#播報imei号 + EventMesh.publish("set_sim_mode")# def sosKey_extint_cb(self,args): power_off = EventMesh.publish("get_power_off_state")#获取关机标识 @@ -1764,35 +1836,40 @@ class BtnDevice(Abstract): EventMesh.publish("publish_message_event_btnInfo",{"func":self.sosKey_timeout_cb,"data":0}) def sosKey_timeout_cb(self, data):# print("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count) - if self.sosKey_press_count >= 10:# + if self.sosKey_press_count == 10:# self.sosKey_press_count = 0 # EventMesh.publish("reset_factor_setiing")# pass - elif self.sosKey_press_count >= 6:# + elif self.sosKey_press_count == 6:# self.sosKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("set_manual_measure_mode",2)#测量血氧 # EventMesh.publish("play_imei_event")#播報imei号 pass - elif self.sosKey_press_count >= 5: - self.sosKey_press_count = 0 - EventMesh.publish("set_manual_measure_mode",3)#测量体温 - pass - elif self.sosKey_press_count >= 4:#拨打app快捷号码 + # elif self.sosKey_press_count >= 5:#功能暂时屏蔽 + # self.sosKey_press_count = 0 + # # EventMesh.publish("stop_led_timer")#设置参数 + # # EventMesh.publish("set_manual_measure_mode",3)#测量体温 + # pass + elif self.sosKey_press_count == 4:#拨打app快捷号码 self.sosKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("play_center_phone")#拨打快捷号码 # EventMesh.publish("call_phonebook_three_call") pass - elif self.sosKey_press_count >= 3:#测试心率 + elif self.sosKey_press_count == 3:#测试心率 self.sosKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("set_manual_measure_mode",1)# pass - elif self.sosKey_press_count >= 2:#播报当前步数 + elif self.sosKey_press_count == 2:#播报当前步数 self.sosKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("play_cur_step_event")# pass - elif self.sosKey_press_count >= 1:#挂断来电 短语音播报 + elif self.sosKey_press_count == 1:#挂断来电 短语音播报 self.sosKey_press_count = 0 - + EventMesh.publish("stop_led_timer")#设置参数 # EventMesh.publish("call_test_event") EventMesh.publish("sos_short_press")#sos短按事件 pass @@ -1922,29 +1999,35 @@ class BtnDevice(Abstract): def wechatKey_timeout_cb(self,data):#微聊键 print("wechatKey_timeout_cb!!!!!!!!!!!!!! ",self.wechatKey_press_count) - if self.wechatKey_press_count >= 10:#短按十次解绑app + if self.wechatKey_press_count == 10:#短按十次解绑app self.wechatKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("open_power_on", 4)#恢复出厂 pass - elif self.wechatKey_press_count >= 6:#短按六次播报imei号 + elif self.wechatKey_press_count == 6:#短按六次播报imei号 self.wechatKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("play_imei_event")#播報imei号 pass - elif self.wechatKey_press_count >= 4:#拨打通讯录号码三 + elif self.wechatKey_press_count == 4:#拨打通讯录号码三 self.wechatKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("call_phonebook_three_call") pass - elif self.wechatKey_press_count >= 3:#拨打通讯录号码二 + elif self.wechatKey_press_count == 3:#拨打通讯录号码二 self.wechatKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 EventMesh.publish("call_phonebook_two_call") pass - elif self.wechatKey_press_count >= 2:#拨打通讯录号码一 + elif self.wechatKey_press_count == 2:#拨打通讯录号码一 + EventMesh.publish("stop_led_timer")#设置参数 self.wechatKey_press_count = 0 EventMesh.publish("call_phonebook_one_call") # EventMesh.publish("interup_call_event")# pass - elif self.wechatKey_press_count >= 1:#播放最后收到的语音 + elif self.wechatKey_press_count == 1:#播放最后收到的语音 self.wechatKey_press_count = 0 + EventMesh.publish("stop_led_timer")#设置参数 call_state = EventMesh.publish("get_call_state") if call_state == 2:#电话拨进需要接听 EventMesh.publish("answer_call_event")#接听电话 diff --git a/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/ui.py b/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/ui.py index 057a90e3..15b52e5b 100644 --- a/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/ui.py +++ b/2.sdk/project/K01/sdk/services/microPython/ports/quectel/core/ui.py @@ -982,6 +982,7 @@ class DialingScreen(Screen): def __init__(self): super().__init__() + self.timer = osTimer() self.meta = None self.meta_type = "popup" self.call_log = {} @@ -1037,6 +1038,17 @@ class DialingScreen(Screen): EventMesh.publish("set_UI_high_priority", 0) EventMesh.publish("set_hangup_mode", 1) voiceCall.callEnd() + self.timer.start(5000,0,self.call_end) + + def Close(self): + self.timer.stop() + + def call_end(self,*argc): + print("call_end!!!!!!!!") + call_state = EventMesh.publish("get_call_state")#设置关机时间 + if call_state != None: + if call_state == 0:#未打通 + EventMesh.publish("load_screen", {"screen": "main_menu"}) def done_return(self): pass diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/main_init.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/main_init.py index f5c01100..90f7a3c7 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/main_init.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/main_init.py @@ -66,7 +66,7 @@ def main_init(): # from ui_WatchFaceScreen import WatchFaceScreen from appFactoryMode import FactoryModeLocationScreen,FactoryModeScreen ,FactoryModeBatTestScreen,FactoryModeHsensorTestScreen,FactoryModeLogScreen - from mgr import setclassTimeManager,setSmsIndexManager,ConfigStoreManager,testSmsSetIPManager,playPowerAudioManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\ + from mgr import setCallStateManager,setclassTimeManager,setSmsIndexManager,ConfigStoreManager,testSmsSetIPManager,playPowerAudioManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\ AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager import ui as _ui @@ -262,6 +262,7 @@ def main_init(): app.append_manager(testSmsSetIPManager()) app.append_manager(setSmsIndexManager()) app.append_manager(setclassTimeManager()) + app.append_manager(setCallStateManager()) except Exception as e: usys.print_exception(e) #print("init21:{}".format(utime.localtime())) diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py index 543a928b..2b45fc0c 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py @@ -575,6 +575,7 @@ def voice_callback(args): if b == True and size_len > 11: tmp = tmp[size_len-11:] + EventMesh.publish("set_call_state",2)#设置关机时间 EventMesh.publish("load_screen", {"screen": "incoming_call","meta":str(tmp)}) elif args[0] == 11: @@ -592,6 +593,7 @@ def voice_callback(args): b = tmp[0].isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了 if b == True and size_len > 11: tmp = tmp[size_len-11:] + EventMesh.publish("set_call_state",1)#设置关机时间 EventMesh.publish("load_screen", {"screen": "on_call","meta":str(tmp)}) elif args[0] == 12: @@ -611,12 +613,13 @@ def voice_callback(args): EventMesh.publish("set_sos_info_call") print('voicecall disconnect end') + EventMesh.publish("set_call_state",0)#设置关机时间 elif args[0] == 13: print('voicecall is waiting, PhoneNO.: ', args[6]) elif args[0] == 14: - + EventMesh.publish("set_call_state",4)#设置关机时间 print('voicecall dialing, PhoneNO.: ', args[6]) EventMesh.publish("set_UI_high_priority",0) EventMesh.publish("load_screen", {"screen": "dialing"}) @@ -2375,7 +2378,7 @@ class CallLogManager(Abstract): def set(self, event, msg): self.check_json = msg[0] self.read_call_log = msg[1] - with open("/usr/static/storage_file/Call_log.json","w+",encoding="utf-8") as fd: + with open("/ext/static/storage_file/Call_log.json","w+",encoding="utf-8") as fd: ujson.dump(self.read_call_log,fd) # def call_usr(self,event,msg): # content = self.log[msg] @@ -3088,6 +3091,22 @@ class testSmsSetIPManager(Abstract):# return [self.newip,self.newcom] +class setCallStateManager(Abstract):#设置电话通话状态 + def __init__(self): + self.call_state = 0 + + def post_processor_after_instantiation(self): + EventMesh.subscribe("set_call_state", self.set_call_state)#设置关机时间 + EventMesh.subscribe("get_call_state", self.get_call_state) + + def set_call_state(self, event, msg): + self.call_state = msg + + + def get_call_state(self, event, msg): + + return self.call_state + class setclassTimeManager(Abstract):#设置上课禁用时间 def __init__(self): self.class_buf = {} diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py index 81f22c6e..27fde64a 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui.py @@ -971,7 +971,7 @@ class DialingScreen(Screen): def __init__(self): super().__init__() self.meta = None - + self.timer = osTimer() self.call_log = {} self.call_log_value = {} self.read_call_log = {} @@ -1026,6 +1026,17 @@ class DialingScreen(Screen): EventMesh.publish("set_UI_high_priority", 0) EventMesh.publish("set_hangup_mode", 1) voiceCall.callEnd() + self.timer.start(5000,0,self.call_end) + + def Close(self): + self.timer.stop() + + def call_end(self,*argc): + call_state = EventMesh.publish("get_call_state")#设置关机时间 + if call_state != None: + if call_state == 0:#未打通 + EventMesh.publish("load_screen", {"screen": "main_menu"}) + def done_return(self): pass