MSGQ_SEND = "MSGQ_SEND"
MSGQ_RECV = "MSGQ_RECV"
+
+ PROFILE_SEND = "profile_SEND"
+ PROFILE_RECV = "profile_RECV"
pcr.add_support(protocol.FACTORY_ProtoCol())
pcr.add_support(protocol.MESSAGE_SOS_ProtoCol())
pcr.add_support(protocol.MSGQ_ProtoCol())
+ pcr.add_support(protocol.profile_ProtoCol())
except Exception as e:
usys.print_exception(e)
try:
if SOS_NUMBER1 != None:
self.sos_numer1 = SOS_NUMBER1
SOS_NUMBER2 = EventMesh.publish("get_storage_config","SOS_NUMBER2")
- if SOS_NUMBER1 != None:
+ if SOS_NUMBER2 != None:
self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
SOS_NUMBER3 = EventMesh.publish("get_storage_config","SOS_NUMBER3")
# print("phonebook_name!!!!!!!!!!!!",phonebook_name)
EventMesh.publish("set_sos_message", phonebook_name)#
EventMesh.publish("load_screen", {"screen": "sos_rev"})
+ EventMesh.publish("update_sos_show",phonebook_name)
+
def send(self, event, msg):
#[XT*334588000000156*0007*MESSAGE]
- send_data = self.PID+"*%s*0005*MSGQ"%(self.imei)
+ send_data = self.PID+"*%s*0004*MSGQ"%(self.imei)
MD5_SIGN = self.pack_MD5_head(send_data)
data = "[%s%s]"%(str(MD5_SIGN),send_data)
#Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
print("MSGQ!!!!!!!!!!!!")
-
+# [XT*YYYYYYYYYYYYYYY*LEN*profile]
+class profile_ProtoCol(ProtoCol):
+ """情景模式"""
+ TYPE = "profile"
+
+
+ def send(self, event, msg):
+
+ #[XT*334588000000156*0007*MESSAGE]
+ send_data = self.PID+"*%s*0007*profile"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+ def recv(self, event, msg):
+ """
+
+ @param event:
+ @param msg: 接收到的下行数据
+ """
+
+ msg = msg[1:-1]
+ msg_s = msg.decode('ascii')
+ msg_s = msg_s.split('profile,')[1]
+ mode = int(msg_s)
+ if mode == 4:
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME == "sos_rev":#在sos求助界面收到该指令啧退出当前界面
+ EventMesh.publish("close_sos_timer")
+ EventMesh.publish("close_motor_infor")#关闭马达和定时器
+ EventMesh.publish("set_UI_high_priority",0)
+ EventMesh.publish("return_prev_screen")
+ print("profile!!!!!!!!!!!!")
+
+ EventMesh.publish(constants.PROTOCOL.PROFILE_SEND)
sos_recv_screen = None
sos_recv_screen_label = None
-sos_recv_screen_comfirm=None
+sos_recv_screen_comfirm =None
sos_recv_screen_label2 = None
sos_recv_screen_label2_btn =None
+sos_recv_new_screen = None
+
+style_cont_sos = lv.style_t()
+style_cont_sos.init()
+style_cont_sos.set_bg_color(lv.color_make(0x23, 0xc1,0xbb))
+style_cont_sos.set_radius(20)
+style_cont_sos.set_pad_left(0)
+style_cont_sos.set_pad_right(0)
+style_cont_sos.set_pad_top(0)
+style_cont_sos.set_pad_bottom(0)
+
class sosrecvScreen(Screen):#设备接收平台发送的
NAME = "sos_rev"
def __init__(self):
self.meta = None
self.meta_type = "popup"
self.timer = osTimer()
+ self.timer1 = osTimer()
self.count = 0
self.sos_state = 0
- EventMesh.subscribe("get_sos_status",self.get_sos_status)
+ self.aud = audio.Audio(0)
+ EventMesh.subscribe("close_sos_timer",self.close_sos_timer)
+
+ EventMesh.subscribe("update_sos_show",self.update_sos_show)
def initialization(self):
+ self.aud.setVolume(11)#设置最大声录音
self.count = 0
self.sos_state = 1
EventMesh.publish("set_UI_high_priority",1)
- global sos_recv_screen,sos_recv_screen_label,sos_recv_screen_label2,sos_recv_screen_comfirm,sos_recv_screen_label2_btn
+ global sos_recv_screen,sos_recv_screen_label,sos_recv_new_screen,sos_recv_screen_label2,sos_recv_screen_comfirm,sos_recv_screen_label2_btn
if sos_recv_screen == None :
sos_recv_screen = lv.obj()
print("sos_recv_screen")
sos_recv_screen_label.set_text(" ")
sos_recv_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN|lv.STATE.DEFAULT)
- sos_recv_screen_comfirm = lv.img(sos_recv_new_btn_screen)
- sos_recv_screen_comfirm.set_size(176, 46)
- sos_recv_screen_comfirm.set_pos(32, 0)
- sos_recv_screen_comfirm.set_src("E:/static/off_icon.png")
+ sos_recv_screen_comfirm = lv.btn(sos_recv_new_btn_screen)
+ sos_recv_screen_comfirm.set_size(200,46)
+ sos_recv_screen_comfirm.set_pos(20,0)
sos_recv_screen_comfirm.add_flag(lv.obj.FLAG.CLICKABLE)
- sos_recv_screen_comfirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ sos_recv_screen_comfirm.add_style(style_cont_sos, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ # sos_recv_screen_comfirm = lv.img(sos_recv_new_btn_screen)
+ # sos_recv_screen_comfirm.set_size(176, 46)
+ # sos_recv_screen_comfirm.set_pos(32, 0)
+ # sos_recv_screen_comfirm.set_src("E:/static/off_icon.png")
+ # sos_recv_screen_comfirm.add_flag(lv.obj.FLAG.CLICKABLE)
+ # sos_recv_screen_comfirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
sos_recv_screen_label2 = lv.label(sos_recv_screen_comfirm)
sos_recv_screen_label2.set_text("确定")
sos_recv_screen_label.set_text(" ")
EventMesh.publish("set_motor_time",[1,2,10*10,10,5])#设置马达参数
+ self.aud.stop()#
+ self.aud.play(1, 1, '/ext/static/SOS_PLAY.mp3') #文件名前面要加上路径
self.timer.start(1*1000,1,self.motor_cb)
-
-
- def get_sos_status(self,event,msg):
- return self.sos_state
+ def close_sos_timer(self,event,msg):
+ self.aud.stop()#
+ self.timer.stop()
+
def confirm(self,e):
self.sos_state = 0
self.timer.stop()
+
EventMesh.publish(constants.PROTOCOL.MESSAGE_SOS_SEND)
EventMesh.publish("close_motor_infor")#关闭马达和定时器
EventMesh.publish("set_UI_high_priority",0)
EventMesh.publish("return_prev_screen")
+
def motor_cb(self,*argc):
EventMesh.publish("system_sleep_rest")#防止黑屏
+ if EventMesh.publish("get_audio_state") == 0:
+ self.aud.stop()#
+ self.aud.play(1, 1, '/ext/static/SOS_PLAY.mp3')
+
self.count+=1
if self.count >= 7:
self.count = 0
EventMesh.publish("set_motor_time",[1,2,10*10,10,5])#设置马达参数
- #
+ def update_sos_show(self,event,msg):
+ global sos_recv_screen_label,sos_recv_new_screen
+ if sos_recv_screen_label == None:
+ return
+ if len(str(msg)) != 0:
+ sos_recv_new_screen.scroll_to(0, 0, lv.ANIM.OFF)#每次更新的时候就从头显示
+ sos_recv_screen_label.set_text("{}".format(msg))
+ else:
+ sos_recv_new_screen.scroll_to(0, 0, lv.ANIM.OFF)
+ sos_recv_screen_label.set_text(" ")
+ pass
def Close(self):
+
+ self.aud.stop()#
+ num = EventMesh.publish("get_volum_size")
+ if num == None:
+ num = 8
+ self.aud.setVolume(num)#恢复原始音量
EventMesh.publish("set_UI_high_priority",0)
self.timer.stop()
EventMesh.publish("close_motor_infor")#关闭马达和定时器
fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
usb_state = EventMesh.publish("get_usb")#
video_state = EventMesh.publish("get_video_state")
- if flag != 0 or usb_state == 1 or usb_state == 3 or fall_down != 0:
+ if flag != 0 or fall_down != 0:
return
- pass
EventMesh.publish("stop_led_timer")#设置参数
EventMesh.publish("call_viode_book_num")
pass
if SOS_NUMBER1 != None:
self.sos_numer1 = SOS_NUMBER1
SOS_NUMBER2 = EventMesh.publish("get_storage_config","SOS_NUMBER2")
- if SOS_NUMBER1 != None:
+ if SOS_NUMBER2 != None:
self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
SOS_NUMBER3 = EventMesh.publish("get_storage_config","SOS_NUMBER3")
if SOS_NUMBER1 != None:
self.sos_numer1 = SOS_NUMBER1
SOS_NUMBER2 = EventMesh.publish("get_storage_config","SOS_NUMBER2")
- if SOS_NUMBER1 != None:
+ if SOS_NUMBER2 != None:
self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
SOS_NUMBER3 = EventMesh.publish("get_storage_config","SOS_NUMBER3")
# "api.xcloudtech.com"
# d_server_port = 9000
jsload_data = ujson.loads(c)
- # print("jsload_data-{}".format(jsload_data))
+ print("jsload_data-{}".format(jsload_data))
# jsload_data = {'data':'111','protocolType':'', 'host':'device.miwitracker.com', 'secretKey': 'bZld0ALsZTt15tKEZhOlLPgbsO75BLTP', 'port':8505, 'bid': '3G', 'extJsonStr': ''}
# ujson.loads(c)
data_tmp = data_tmp.split(']')[0] #去掉]
EventMesh.publish(constants.EVENT.SET_PING, data_tmp.split(',')[1])
if EventMesh.model == 'D15':
- if str(data_tmp) == "1":
- EventMesh.publish(constants.PROTOCOL.JPREG_SEND)
- EventMesh.publish(constants.PROTOCOL.MEMBERS_SEND)
+ EventMesh.publish(constants.PROTOCOL.JPREG_SEND)
+ EventMesh.publish(constants.PROTOCOL.MEMBERS_SEND)
class KA_ProtoCol(ProtoCol):
"""心跳"""
usb_state = EventMesh.publish("get_usb")#
video_state = EventMesh.publish("get_video_state")
sos_dialing = EventMesh.publish("get_sos_state_out")#正在拨打sos电话
- if flag != 0 or usb_state == 1 or usb_state == 3 or fall_down != 0 or video_state != 0 or sos_dialing != 0: #电话在打入或者 在充电不允许视频通话
+ if flag != 0 or fall_down != 0 or video_state != 0 or sos_dialing != 0: #电话在打入或者 在充电不允许视频通话
EventMesh.publish(constants.PROTOCOL.CALLING_SEND,1)
else:
EventMesh.publish(constants.PROTOCOL.CALLING_SEND,0)
if SOS_NUMBER1 != None:
self.sos_numer1 = SOS_NUMBER1
SOS_NUMBER2 = EventMesh.publish("get_storage_config","SOS_NUMBER2")
- if SOS_NUMBER1 != None:
+ if SOS_NUMBER2 != None:
self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
SOS_NUMBER3 = EventMesh.publish("get_storage_config","SOS_NUMBER3")
# PID = "SZKW"
elif server_type == 2:
# test.iot.socket.thisiot.com:9999
- d_server_addr = "test.iot.socket.thisiot.com"
+ d_server_addr = "iot.socket.thisiot.com"
d_server_port = 9999
- d_md5_key = "3JyCjsw4ryXKzjzudayY"
- d_PID = "qAELPTKmFanR4RHe"
+ d_md5_key = "SZYhyGhroQ3xFKFWZq1g"
+ d_PID = "oxLwDqcwJCtiPSRu"
+
elif server_type == 3:
d_server_addr = "tcp.zhihuixuexiao.com"
d_server_port = 2346
print("sign_data:{} sonce_data:{}".format(md5_data,sign_data))
# sign_data = MD5_head
# http://8.134.110.49:31379/dev/device/check?imei=&bid=sonce=sign=
- ip_addr = "test.iot.api.thisiot.com"
- url = "http://{}/dev/device/check?imei={}&bid={}&sonce={}&sign={}".format(ip_addr,imei,pid_data,sonce_data,sign_data)
+ ip_addr = "iot.api.thisiot.com"
+ # url = "http://{}/dev/device/check?imei={}&bid={}&sonce={}&sign={}".format(ip_addr,imei,pid_data,sonce_data,sign_data)
+ url = "http://app.api.thisiot.com/dev/device/check?imei={}&bid={}&sonce={}&sign={}".format(imei,pid_data,sonce_data,sign_data)
response = request.get(url)
data_tmp ={}
# "api.xcloudtech.com"
# d_server_port = 9000
jsload_data = ujson.loads(c)
- print("jsload_data-{}".format(jsload_data))
+ # print("jsload_data-{}".format(jsload_data))
# jsload_data = {'data':'111','protocolType':'', 'host':'device.miwitracker.com', 'secretKey': 'bZld0ALsZTt15tKEZhOlLPgbsO75BLTP', 'port':8505, 'bid': '3G', 'extJsonStr': ''}
# ujson.loads(c)
EventMesh.publish("set_new_key", str(secretKey))#获取pid和key
EventMesh.publish("set_new_pid",str(pid))#获取pid和key
-
- self.reconnect_timer_cb()#重连设备
+ self.reconnect_flag = 0
+ self.reconnect()#重连设备
EventMesh.publish("set_server_state",1)#获取修改服务器状态
else:
self.md5_key = server_data[0]
self.PID = server_data[1]
- print("init md5PID2",self.md5_key,self.PID)
+ # print("init md5PID2",self.md5_key,self.PID)
def initialization(self, *args, **kwargs):
EventMesh.subscribe(self.TYPE + "_SEND", self.handler)
def close_jrtc_event(self,event,msg):
print("close_jrtc_event")
-
jrtc.close(0)
pass
def clear_jrtc_init_state(self,event,msg):
self.second_count += 1
self.show_time()
-
if call_state != 5:
self.time_count+=1
- if self.time_count >= 1*60 or (call_state == 0 and self.time_count >= 5 and self.second_count != 0):
+ if self.time_count >= 1*60 or call_state == 0:
self.time_count = 0
self.timer1.stop()
call_id = str(EventMesh.publish("get_vedio_call_id"))#
if SOS_NUMBER1 != None:
self.sos_numer1 = SOS_NUMBER1
SOS_NUMBER2 = EventMesh.publish("get_storage_config","SOS_NUMBER2")
- if SOS_NUMBER1 != None:
+ if SOS_NUMBER2 != None:
self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
SOS_NUMBER3 = EventMesh.publish("get_storage_config","SOS_NUMBER3")
if SOS_NUMBER1 != None:
self.sos_numer1 = SOS_NUMBER1
SOS_NUMBER2 = EventMesh.publish("get_storage_config","SOS_NUMBER2")
- if SOS_NUMBER1 != None:
+ if SOS_NUMBER2 != None:
self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
SOS_NUMBER3 = EventMesh.publish("get_storage_config","SOS_NUMBER3")