def timer_FactoryModeLocation_cb(self, *args, **kwargs):
EventMesh.publish("system_sleep_rest")#防止黑屏
self.timer_c += 1
- if self.timer_c >= 5:
+ if self.timer_c >= 7:
get_location_flag = EventMesh.publish("get_location_flag")
self.timer_c = 0
if get_location_flag != None:
if(get_location_flag == 0):
EventMesh.publish(constants.EVENT.START_LOCATION_TEST) #测试模式
+ self.time_count = utime.mktime(utime.localtime())
def GET_LOCATION_DATA(self, event, msg):
# print("GPS:{}".format(msg[0]))
if len(msg[0]) > 1 : #GPS
GNSS_DATA = "GNSS:------\n"
-
-
- rmc_data = msg[0][1].split("RMC")
- gsv_data = msg[0][1].split("GSV")
- if len(rmc_data) >= 2 :
- rmc_data = rmc_data[1:]
- rmc_data = rmc_data[0].split("\r\n")
- rmc_tmp = rmc_data[0].split(",")
- if len(rmc_tmp) >= 2:
- GNSS_DATA = GNSS_DATA + "{},{},{}\n".format(rmc_tmp[2],rmc_tmp[3],rmc_tmp[5])
- if rmc_tmp[2] == 'A':
- if self.GNSS_status == 0:
- self.time_GNSS = time_tmp-self.time_count
- EventMesh.txt_log("test location time:{}".format(self.time_GNSS))
-
- self.time_count = utime.mktime(utime.localtime())
- self.GNSS_status = 1
- else:
- self.GNSS_status = 0
- #self.time_GNSS = 0
- _DATA += "定位时间:{};{}秒\n".format(self.time_GNSS,time_tmp-self.time_count)
- if len(gsv_data) >= 2 :
- gsv_data = gsv_data[1:]
- GSV_dict= {}
- for i in range(len(gsv_data)) :
- gsv_data[i] = gsv_data[i].split("\r\n")[0]
- gsv_tmp = gsv_data[i].split(",")
- if len(gsv_tmp) < 7 :
- break
- gsv_tmp = gsv_tmp[4:]
- #print("gsv_tmp:{}".format(gsv_tmp))
- for i in range(len(gsv_tmp)) :
- if i % 4 == 0:
- GSV_dict[gsv_tmp[i]] = gsv_tmp[i+3]
- #print("GSV_dict:{}:[{}]".format(gsv_tmp[i],gsv_tmp[i+3]))
- if len(gsv_tmp)-i < 4:
- break
+ gnss_data = msg[0][0]
+ if gnss_data :
+ GNSS_DATA = GNSS_DATA + "{},{},{}\n".format("A",gnss_data["latitude"],gnss_data["longitude"])
+
+ self.time_GNSS = time_tmp-self.time_count
+ EventMesh.txt_log("test location time:{}".format(self.time_GNSS))
+ self.time_count = utime.mktime(utime.localtime())
+ else:
+
+ GNSS_DATA = GNSS_DATA + "{},{},{}\n".format("V",0,0)
+ _DATA += "定位时间:{};{}秒\n".format(self.time_GNSS,time_tmp-self.time_count)
+ GSV_dict = msg[0][1]
+ if GSV_dict :
count = 0
try:
for j in range(200):
if count % 2 == 0:
GNSS_DATA+="\n"
- if count > 30:
+ if count > 50:
break
except Exception as e:
usys.print_exception(e)
#EventMesh.txt_log("START_LOCATION")
# pm.autosleep(0)#唤醒
# pm.sclkEx_set(0, 1, 5)
+ GSV_dict= {}
while self.location_flag == 1:
try :
if self.location_check_data_timer_count >= 5 :#5秒查一次基站数据和wifi数据
self.location_check_data_timer_count = 0
#print(self.location_timer_count)
- #GSV_dict= {}
+ GSV_dict= {}
#检查GNSS数据
if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2:
#print("gsv_tmp:{}".format(gsv_tmp))
for i in range(len(gsv_tmp)) :
if i % 4 == 0:
- #GSV_dict[gsv_tmp[i]] = gsv_tmp[i+3]
+ GSV_dict[gsv_tmp[i]] = gsv_tmp[i+3]
try:
#print("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3]))
if gsv_tmp[i+3] != "" :
self.location_timer_count = 0
if len(gnss_r_data) >= 1:
if gnss_r_data[0] > 0:
- EventMesh.publish("PUSH_LOCATION_DATA", [gnss_r_data,self.wifi_data,self.cell_data])
+ EventMesh.publish("PUSH_LOCATION_DATA", [[self.gps_data,GSV_dict],self.wifi_data,self.cell_data])
if self.gps_data != {} : #发送数据
EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
self.location_queue.put(constants.PROTOCOL.UD_SEND)