voiceCall.callEnd()
return
EventMesh.publish("set_call_state",4)##设置通话状态
- EventMesh.publish("set_interrup_incall",0)
- EventMesh.publish("set_UI_high_priority",0)
+
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME != "dialing_noplay_popup":
+ EventMesh.publish("set_interrup_incall",0)
+ EventMesh.publish("set_UI_high_priority",0)
EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
elif args[0] == 15:
self.normal_oldtotalmin = 0
self.normal_flag = 0
self.normal_count = 0
+
+ self.dev_state = 0
# #print("hsensor.open_heart:%d\r\n"%(self.hsensor.open_heart()))
print("DeviceInfoManager:3")
self.i2c0 = I2C(I2C.I2C0, I2C.FAST_MODE)
EventMesh.subscribe(constants.EVENT.STOP_TEMP, self.stop_temp)
EventMesh.subscribe(constants.EVENT.GET_TEMP, self.get_temp)
+ EventMesh.subscribe("get_dev_state",self.get_dev_state)
+ EventMesh.subscribe("set_dev_state",self.set_dev_state)
+
print("post_processor_after_instantiation:2")
self.timer_push_schedule.start(10000, 1, self.publish_event_cb)
# self.timer_pusht_test.start(2000, 1, self.publish_test)
# if flip_sw == 1:
# EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ def get_dev_state(self, event, msg):
+ return self.dev_state
+ def set_dev_state(self, event, msg):
+ self.dev_state = msg
+
def publish_event_cb(self, *args, **kwargs):
EventMesh.publish("publish_message_event_DeviceInfo",{"func":self.publish_event,"data":0})
def publish_event(self,data):
#print("Location_send1")
if self.location_queue.empty() == True:
return
- server_data = server_init()
- # print("SockManager:server_data:{}".format(server_data))
- server_addr = server_data[0]
- server_port = server_data[1]
- ip_infor = EventMesh.publish("get_new_ip_com")
- print("ip_infor1:{} \n\n\n".format(ip_infor))
-
- if ip_infor != None: #已经改过服务器
- server_addr = ip_infor[0]
- server_port = ip_infor[1]
- d_server_addr = "device.miwitracker.com"
- d_server_port = 8505
- print("server_addr:{} server_port:{}".format(server_addr,server_port))
- self.date_info = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
- self.date_info = self.date_info[2:]
- if server_addr == d_server_addr and server_port == d_server_port:
-
- data = RTC().datetime()
- hour = data[4]
- min = data[5]
- sec = data[6]
-
- week = data[3]
-
- year = data[0]#年
- month = data[1]#月
- day = data[2]#日
- year_date = int(str(year)[2:])
- # print("year_date",year_date)
- self.date_info = "%02d"%(day)+"%02d"%(month)+"%02d"%(year_date)+','+"%02d"%(hour)+"%02d"%(min)+"%02d"%(sec)#云米要日月年
- # self.date_info = "%02d"%(utime.localtime()[1])+"%02d"%(utime.localtime()[2])+"%02d"%(year_date)+','+"%02d"%(utime.localtime()[3])+"%02d"%(utime.localtime()[4])+"%02d"%(utime.localtime()[5])
- # print("date_info",self.date_info)
-
- #date = "180916,025723"
- date = self.date_info
- #date = "180916,025723"
- GPS_type = "V"
- latitude = "0.000000,N"
- longitude = "0.000000,E"
- speed = "0.00"
- direction = "0.0"
- high = "100.0"
- number = "0"
- precision = "24"
- if msg[0] :#有GPS数据
- GPS_type = "A"
- # 纬度
- latitude = msg[0]["latitude"]
- # 经度
- longitude = msg[0]["longitude"]
- # 速度
- speed = msg[0]["speed"]
- # 方向
- direction = "0"
- if msg[0]["direction"] :
- direction = msg[0]["direction"]
- # 高度
- high = msg[0]["high"]
- high_tmp = high.split(".")
- if len(high_tmp) >= 2 :
- high = "%s"%(high_tmp[0])
- # 讯号质量:搜索到的卫星数目
- number = msg[0]["number"]
- precision = msg[0]["precision"]
- #date = msg[0]["date"]
-
- #gsm 信号强度
- gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig"))
- # 电池电量百分比
- bat_tmp = EventMesh.publish("screen_get_battery")
- battery_caption = str(bat_tmp[1])
- #步数
- old_step = 0
- step = 0
- step = EventMesh.publish("get_old_step_value")
- if step != None:
- tmp_data = EventMesh.publish("get_storage_config","old_step_new")
- if tmp_data != None:
- old_step = tmp_data
- if old_step != step:
- EventMesh.publish("set_storage_config",["old_step",step])
- EventMesh.publish("set_storage_config",["old_step_new",step])
- else:
- step = 0
- old_step = step
- # step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
- #翻转次数
- turn_count = "0"
- #终端状态
- state = "00000000"
- #基站数据
- CELL_num = len(msg[2])
- CELL_data = "1," #时延
- if msg[2] != []:
- for CELL in msg[2] :
- if CELL[0] == 0 :
- CELL_data += "%X,"%(int(CELL[2])) #MCC
- CELL_data += str(CELL[3]) +","#MNC
- CELL_data += str(CELL[5]) +","#tac,区域码
- CELL_data += str(CELL[1]) +","#基站编号 CID
- CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
- else :
- CELL_data += str(CELL[5]) +","#tac,区域码
- CELL_data += str(CELL[1]) +","#基站编号 CID
- CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
- CELL_data = CELL_data[:(len(CELL_data)-1)]
- #WIFI数据
- WIFI_num = 0
- WIFI_data = ""
- if msg[1] :
- WIFI_num = msg[1][0]
- i = 0
- for MAC in msg[1][1] :
- WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
- i += 1
- WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
- WIFI_data = WIFI_data.lower()
- #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\
- # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
- #定位数据
- send_data = "%s,%s,%s"%(date,GPS_type,latitude)
- send_data += ",%s,%s,%s"%(longitude,speed,direction)
- send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
- send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
- send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
- send_data += ",%d,%s"%(WIFI_num,WIFI_data)
- send_data+=",%s"%(precision)
- #print("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size()))
while True:
if self.location_queue.empty() == False:
TYPE = self.location_queue.get()
+ server_data = server_init()
+ # print("SockManager:server_data:{}".format(server_data))
+ server_addr = server_data[0]
+ server_port = server_data[1]
+ ip_infor = EventMesh.publish("get_new_ip_com")
+ print("ip_infor1:{} \n\n\n".format(ip_infor))
+
+ if ip_infor != None: #已经改过服务器
+ server_addr = ip_infor[0]
+ server_port = ip_infor[1]
+ d_server_addr = "device.miwitracker.com"
+ d_server_port = 8505
+ print("server_addr:{} server_port:{}".format(server_addr,server_port))
+ self.date_info = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
+ self.date_info = self.date_info[2:]
+ if server_addr == d_server_addr and server_port == d_server_port:
+
+ data = RTC().datetime()
+ hour = data[4]
+ min = data[5]
+ sec = data[6]
+
+ week = data[3]
+
+ year = data[0]#年
+ month = data[1]#月
+ day = data[2]#日
+ year_date = int(str(year)[2:])
+ # print("year_date",year_date)
+ self.date_info = "%02d"%(day)+"%02d"%(month)+"%02d"%(year_date)+','+"%02d"%(hour)+"%02d"%(min)+"%02d"%(sec)#云米要日月年
+ # self.date_info = "%02d"%(utime.localtime()[1])+"%02d"%(utime.localtime()[2])+"%02d"%(year_date)+','+"%02d"%(utime.localtime()[3])+"%02d"%(utime.localtime()[4])+"%02d"%(utime.localtime()[5])
+ # print("date_info",self.date_info)
+
+ #date = "180916,025723"
+ date = self.date_info
+ #date = "180916,025723"
+ GPS_type = "V"
+ latitude = "0.000000,N"
+ longitude = "0.000000,E"
+ speed = "0.00"
+ direction = "0.0"
+ high = "100.0"
+ number = "0"
+ precision = "24"
+ if msg[0] :#有GPS数据
+ GPS_type = "A"
+ # 纬度
+ latitude = msg[0]["latitude"]
+ # 经度
+ longitude = msg[0]["longitude"]
+ # 速度
+ speed = msg[0]["speed"]
+ # 方向
+ direction = "0"
+ if msg[0]["direction"] :
+ direction = msg[0]["direction"]
+ # 高度
+ high = msg[0]["high"]
+ high_tmp = high.split(".")
+ if len(high_tmp) >= 2 :
+ high = "%s"%(high_tmp[0])
+ # 讯号质量:搜索到的卫星数目
+ number = msg[0]["number"]
+ precision = msg[0]["precision"]
+ #date = msg[0]["date"]
+
+ #gsm 信号强度
+ gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig"))
+ # 电池电量百分比
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ battery_caption = str(bat_tmp[1])
+ #步数
+ old_step = 0
+ step = 0
+ step = EventMesh.publish("get_old_step_value")
+ if step != None:
+ tmp_data = EventMesh.publish("get_storage_config","old_step_new")
+ if tmp_data != None:
+ old_step = tmp_data
+ if old_step != step:
+ EventMesh.publish("set_storage_config",["old_step",step])
+ EventMesh.publish("set_storage_config",["old_step_new",step])
+ else:
+ step = 0
+ old_step = step
+ # step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
+ #翻转次数
+ turn_count = "0"
+ #终端状态
+ # state = "00000000"
+ state = "%08X"%(EventMesh.publish("get_dev_state"))
+ #基站数据
+ if type(TYPE) == list:#队列里的数据有终端状态,则用队里的终端状态
+ if len(TYPE)>= 2 :
+ state = "%08X"%(TYPE[1])
+ CELL_num = len(msg[2])
+ CELL_data = "1," #时延
+ if msg[2] != []:
+ for CELL in msg[2] :
+ if CELL[0] == 0 :
+ CELL_data += "%X,"%(int(CELL[2])) #MCC
+ CELL_data += str(CELL[3]) +","#MNC
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ else :
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ CELL_data = CELL_data[:(len(CELL_data)-1)]
+ #WIFI数据
+ WIFI_num = 0
+ WIFI_data = ""
+ if msg[1] :
+ WIFI_num = msg[1][0]
+ i = 0
+ for MAC in msg[1][1] :
+ WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
+ i += 1
+ WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
+ WIFI_data = WIFI_data.lower()
+ #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\
+ # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
+ #定位数据
+ send_data = "%s,%s,%s"%(date,GPS_type,latitude)
+ send_data += ",%s,%s,%s"%(longitude,speed,direction)
+ send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
+ send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
+ send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
+ send_data += ",%d,%s"%(WIFI_num,WIFI_data)
+ send_data+=",%s"%(precision)
+ #print("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size()))
print("Location_send3:{}-{}".format(TYPE,send_data))
- EventMesh.publish(TYPE,send_data)
+ if type(TYPE) == list:
+ EventMesh.publish(TYPE[0],send_data)
+ else:
+ EventMesh.publish(TYPE,send_data)
else :
break
if number != None:
if len(number) > 0:
+ sos_state = EventMesh.publish("get_dev_state")
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第16位=1
+ EventMesh.publish("set_dev_state",sos_state)
+
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
EventMesh.publish("save_phonename",number[0])
EventMesh.publish("save_phonenum",number[0])
EventMesh.publish("set_sos_num",0)
# print("call_timer_cb:{}".format(self.callnumer))
EventMesh.publish("save_phonename",str(self.callnumer))
EventMesh.publish("save_phonenum",str(self.callnumer))
+ sos_state = EventMesh.publish("get_dev_state")
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第16位=1
+ EventMesh.publish("set_dev_state",sos_state)
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
def close_sos_timer(self,event,msg):