From: dxy <1731678236qq.com> Date: Thu, 21 Aug 2025 03:35:52 +0000 (+0800) Subject: 1.sos配置字段字符串更改 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=5c6dfbcbc697206505e0a8bc0fdf9f02ae1e6adf;p=mirrors%2FASR1603_G5.git 1.sos配置字段字符串更改 2.蓝牙开关状态更改 --- 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 768917c3..7e555757 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 @@ -356,14 +356,14 @@ class AI_UART(): elif jsload_data["event"]=="get_ble_switch": ble_switch_flag = EventMesh.publish("get_storage_config","switch_ble_state")#ble开关 if ble_switch_flag == None: - ble_switch_flag = "0" + ble_switch_flag = "1" EventMesh.publish("send_ble_switch_toble",str(ble_switch_flag)) ack_flag=1 pass elif jsload_data["event"]=="get_bt_switch": bt_switch_flag = EventMesh.publish("get_storage_config","switch_bt_state")#bt开关 if bt_switch_flag == None: - bt_switch_flag = "0" + bt_switch_flag = "1" EventMesh.publish("send_bt_switch_toble",bt_switch_flag) ack_flag=1 pass @@ -408,7 +408,7 @@ class AI_UART(): "event": "switch_ble_state", "data":{ - "switch_ble_state":"0" + "switch_ble_state":"1" } } @@ -421,7 +421,7 @@ class AI_UART(): "event": "switch_ble_state", "data":{ - "switch_ble_state":"1" + "switch_ble_state":"0" } } @@ -434,7 +434,7 @@ class AI_UART(): "event": "switch_bt_state", "data":{ - "switch_bt_state":"0" + "switch_bt_state":"1" } } @@ -447,7 +447,7 @@ class AI_UART(): "event": "switch_bt_state", "data":{ - "switch_bt_state":"1" + "switch_bt_state":"0" } } @@ -880,12 +880,12 @@ class AI_dev(Abstract): def ble_switch_flag_time_cb(self,*args): bt_switch_flag = EventMesh.publish("get_storage_config","switch_bt_state")#bt开关 if bt_switch_flag == None: - bt_switch_flag = "0" + bt_switch_flag = "1" EventMesh.publish("send_bt_switch_toble",str(bt_switch_flag)) EventMesh.publish("send_imei_to_ble") ble_switch_flag = EventMesh.publish("get_storage_config","switch_ble_state")#ble开关 if ble_switch_flag == None: - ble_switch_flag = "0" + ble_switch_flag = "1" EventMesh.publish("send_ble_switch_toble",str(ble_switch_flag)) pass print("ble_switch_flag_time_cb!!!!!!!") @@ -4592,7 +4592,15 @@ class AI_VC(Abstract): def kws_even(self,event = None,msg= None): EventMesh.publish("publish_AI_btnInfo",{"func":self.kws_even_cb}) def kws_even_cb(self): + if EventMesh.publish("get_sos_flag") == 1: + return print("kws_even_cb") + if EventMesh.publish("get_voice_record_flag") == 1:#停止静默录音 + if EventMesh.publish("get_voice_record_mode") == 2:#语音留言不能被打断 + return + elif EventMesh.publish("get_voice_record_mode") == 1: #静默录音需要打断 + EventMesh.publish("stop_voice_record")#停止静默录音 + if self.VC_mode == 0: self.Close() if dev_type == "7PIN" : 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 8eb67a39..6f86bd0f 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 @@ -297,6 +297,7 @@ class AI_alarm(Abstract): self.alarm_array[aIndex]["state"] = "0" print("aIndex{}".format(self.alarm_array)) EventMesh.publish("set_storage_config",["alarm_list",self.alarm_array]) + EventMesh.publish("GET_NEED_ALARM_REPORT_INFO") name = alarm_TTS_str["name"] AringTimes = alarm_TTS_str["ringTimes"] 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 61198aed..25b6c57f 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 @@ -832,9 +832,9 @@ def playpolad_data(data): if data[0] != 0xff and data[1] !=0xfe and data[2] != 0x03 and data[3] !=0x03: return - print(type(data)) + # print(type(data)) json_bytes = data[8:] - print(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]) + # print(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]) # 2. 将二进制JSON转换为字符串(使用UTF-8解码) json_str = json_bytes.decode('utf-8') print("解析出的JSON字符串:") @@ -938,7 +938,13 @@ class sosInfoCallManager(Abstract): EventMesh.subscribe("set_sos_info_call", self.set_sos_info_call) EventMesh.subscribe("set_sos_list_info",self.set_sos_list_info) EventMesh.subscribe("stop_sos_call",self.stop_sos_call) - + EventMesh.subscribe("set_sos_config",self.set_sos_config) + def set_sos_config(self,event,msg): + # sos_config:{'enable110': '1', 'pressDuration': 3, 'enableSos': '0'} + print("set_sos_config:{}".format(msg)) + self.sos_config = msg + # self.start_phone110112() + pass def get_sos_flag(self,event,msg): return self.sos_flag # import EventMesh @@ -963,14 +969,23 @@ class sosInfoCallManager(Abstract): pass def start_phone110112(self): + print("start_phone110112:{} self.sos_config:{}".format(self.call_state,self.sos_config)) if self.call_state == 0: if self.sos_config != {}: - enable110 = self.sos_config["state"] - if enable110 == 1: - p110 = self.sos_config["enable_110"] - self.phone110112 = p110 - self.sos_timer1.start(2000, 0, self.phone110112_cb) - pass + if "enableSos" in self.sos_config: + enableSos = self.sos_config["enableSos"] + print("enableSos{} {}".format(enableSos,self.sos_config["enable110"])) + if enableSos == "0": + if "enable110" in self.sos_config: + p110 = self.sos_config["enable110"] + if p110 == "0": + + self.phone110112 = "110" + self.sos_timer1.start(2000, 0, self.phone110112_cb) + elif p110 == "1": + self.phone110112 = "112" + self.sos_timer1.start(2000, 0, self.phone110112_cb) + def sos_call_out_phone(self, msg):#电话拨出去 if self.call_state == 0: ret = voiceCall.callStart(self.sos_phone_num) @@ -994,21 +1009,10 @@ class sosInfoCallManager(Abstract): if self.call_state == 0: EventMesh.publish("stop_voice_record") #电话优先级最高 EventMesh.publish("stop_AI_record") - voiceCall.callStart(self.phone110112) + ret = voiceCall.callStart(self.phone110112) + # print("ret:{} {}".format(ret,self.phone110112)) self.phone110112 = "" -# if ("btStateSwitch".equals(testType)) { -# return testBtStateDispatch(deviceId); -# } else if ("btScan".equals(testType)) { -# return testBtScanDispatch(deviceId); -# } else if ("getBtState".equals(testType)) { -# return testGetBtStateDispatch(deviceId); -# } else if ("getConnectRecordList".equals(testType)) { -# return testGetConnectRecordListDispatch(deviceId); -# } else if ("connectBt".equals(testType)) { -# return testConnectBtDispatch(deviceId); -# } else if ("disconnectBt".equals(testType)) { -# return testDisconnectBtDispatch(deviceId); -# } + def set_sos_list_info(self,event,msg): self.sos_list = msg @@ -1989,18 +1993,18 @@ class IOTWeb_HRProtoCol(ProtoCol): if rest == "unbind": #解绑需要开启蓝牙广播 self.btstate = 0 if self.blestate == 0: - EventMesh.publish("set_storage_config",["switch_ble_state","0"]) - EventMesh.publish("send_ble_switch_toble","0") + EventMesh.publish("set_storage_config",["switch_ble_state","1"]) + EventMesh.publish("send_ble_switch_toble","1") - EventMesh.publish("set_storage_config",["switch_bt_state","0"]) - EventMesh.publish("send_bt_switch_toble","0") + EventMesh.publish("set_storage_config",["switch_bt_state","1"]) + EventMesh.publish("send_bt_switch_toble","1") self.blestate=1 elif rest == "bind": #绑定需要关闭蓝牙广播 self.blestate =0 if self.btstate == 0: - EventMesh.publish("set_storage_config",["switch_ble_state","1"]) - EventMesh.publish("send_ble_switch_toble","1") + EventMesh.publish("set_storage_config",["switch_ble_state","0"]) + EventMesh.publish("send_ble_switch_toble","0") self.btstate=1 #定位周期 @@ -2458,6 +2462,7 @@ class IOTWeb_sos_configProtoCol(ProtoCol): sos_config = msg["data"] print("recv sos_config{} type:{}".format(sos_config,type(msg))) EventMesh.publish("set_storage_config",["sos_config",sos_config]) + EventMesh.publish("set_sos_config",sos_config) sos_config = EventMesh.publish("get_storage_config","sos_config") print("sos_config:{} type:{}".format(sos_config,sos_config["enable110"])) EventMesh.publish(WEB_CMD_ENUM.SOS_CONFIG_S_CMD) @@ -2584,15 +2589,17 @@ class IOTWeb_voice_recordProtoCol(ProtoCol): record_mode = EventMesh.publish("get_voice_record_mode") if record_mode == None: record_mode = 0 - if record_mode != 2:#语音留言不允许打断 - s_rest = "1" + get_VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag") + if get_VC_satrt_flag == None: + get_VC_satrt_flag = 0 + if record_mode == 2 or get_VC_satrt_flag == 1:# 如果在AI对话 或者语音留言不允许静默录音 + s_rest = "0" EventMesh.publish(WEB_CMD_ENUM.VOICE_RECORD_S_CMD,s_rest) - EventMesh.publish("start_voice_record",1) - + EventMesh.publish("stop_voice_record") else: - s_rest = "0" + s_rest = "1" EventMesh.publish(WEB_CMD_ENUM.VOICE_RECORD_S_CMD,s_rest) - + EventMesh.publish("start_voice_record",1) print("开始录音") #设备解绑 @@ -2648,12 +2655,12 @@ class IOTWeb_unbind_devProtoCol(ProtoCol): rest = data["rest"] if rest == "success": play_str = "设备解绑成功" - EventMesh.publish("set_storage_config",["switch_ble_state","0"]) - EventMesh.publish("send_ble_switch_toble","0") + EventMesh.publish("set_storage_config",["switch_ble_state","1"]) + EventMesh.publish("send_ble_switch_toble","1") - EventMesh.publish("set_storage_config",["switch_bt_state","0"]) - EventMesh.publish("send_bt_switch_toble","0") + EventMesh.publish("set_storage_config",["switch_bt_state","1"]) + EventMesh.publish("send_bt_switch_toble","1") EventMesh.publish("play_tts",[play_str,1]) pass else: @@ -2703,11 +2710,11 @@ class IOTWeb_user_unbind_devProtoCol(ProtoCol): # } self.btstate = 0 self.blestate = 0 - EventMesh.publish("set_storage_config",["switch_ble_state","0"]) #用户解绑设备需要开启广播 开启经典蓝牙 - EventMesh.publish("send_ble_switch_toble","0") + EventMesh.publish("set_storage_config",["switch_ble_state","1"]) #用户解绑设备需要开启广播 开启经典蓝牙 + EventMesh.publish("send_ble_switch_toble","1") - EventMesh.publish("set_storage_config",["switch_bt_state","0"]) - EventMesh.publish("send_bt_switch_toble","0") + EventMesh.publish("set_storage_config",["switch_bt_state","1"]) + EventMesh.publish("send_bt_switch_toble","1") EventMesh.publish(WEB_CMD_ENUM.USER_UNBIND_DEV_S) print("recv user_unbind_dev{}".format(msg)) #下发位子留言 @@ -3191,6 +3198,21 @@ class IOTWeb_switch_bt_stateProtoCol(ProtoCol): # 通过websocket发送到服务器端 date_tmp = utime.localtime() time_tmp = utime.mktime(date_tmp) + # { + # "cmd":"dispatch_rest", + # "ts":1738283829, + # "msg":"消息收到响应", + # "data":{ + # "cmd":"switch_bt_state", + # "rest":"success|error", + # "msg":"收到蓝牙已打开/蓝牙已关闭指令" + # } + # } + s_msg = "蓝牙已关闭指令" + if msg == "1": + s_msg = "收到蓝牙已打开" + elif msg == "0": + s_msg = "蓝牙已关闭指令" switch_bt_state = { "cmd":"dispatch_rest", "ts":time_tmp, @@ -3198,7 +3220,7 @@ class IOTWeb_switch_bt_stateProtoCol(ProtoCol): "data":{ "cmd":"switch_bt_state", "rest":"success", - "msg":"蓝牙已打开" + "msg":s_msg } } send_data = b'' @@ -3212,19 +3234,22 @@ class IOTWeb_switch_bt_stateProtoCol(ProtoCol): @param event:上行下发switch_bt_state @param msg: 接收到的下行数据 """ + s_state = "1" if "data" in msg: data = msg["data"] if data == "0": + s_state = "0" EventMesh.publish("set_storage_config",["switch_bt_state","0"]) EventMesh.publish("send_bt_switch_toble","0") pass elif data == "1": + s_state = "1" EventMesh.publish("set_storage_config",["switch_bt_state","1"]) EventMesh.publish("send_bt_switch_toble","1") pass print("recv switch_bt_state{}".format(msg)) - EventMesh.publish(WEB_CMD_ENUM.SWITCH_BT_STATE_S_CMD) + EventMesh.publish(WEB_CMD_ENUM.SWITCH_BT_STATE_S_CMD,s_state) #蓝牙扫描 class IOTWeb_bt_scanProtoCol(ProtoCol): @@ -3317,7 +3342,7 @@ class IOTWeb_get_bt_stateProtoCol(ProtoCol): print("recv bt_state{}".format(msg)) switch_bt_state = EventMesh.publish("get_storage_config","switch_bt_state") if switch_bt_state == None: - switch_bt_state = 0 + switch_bt_state = "1" EventMesh.publish(WEB_CMD_ENUM.GET_BT_STATE_S,str(switch_bt_state)) diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/voice_record.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/voice_record.py index 0aafb25a..385aa4b4 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/voice_record.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/voice_record.py @@ -66,7 +66,7 @@ class VOICE_RECORD(Abstract): #静默录音 return self.voice_mode def start_voice_record(self,event,msg): if EventMesh.publish("get_sos_flag") == 1: - return + return -1 get_VC_satrt_flag = EventMesh.publish("get_VC_satrt_flag") if get_VC_satrt_flag == None: get_VC_satrt_flag = 0 @@ -99,7 +99,7 @@ class VOICE_RECORD(Abstract): #静默录音 self.voice_timer_out.start(10*60*1000,0,self.timerOut) # EventMesh.publish("open_websocket_timer") print("start_voice_record") - return 1 + return 0 def timerOut(self,*argc): EventMesh.publish("stop_voice_record") pass