update: del remote bio

This commit is contained in:
JackSun-qc 2022-03-17 17:43:52 +08:00
parent 9f9fdb9f28
commit becc4647a3
2 changed files with 21 additions and 38 deletions

View File

@ -64,9 +64,12 @@ class QuecThing(object):
quecIot.setServer(1, "iot-south.quectel.com:2883")
quecIot.setConnmode(1)
def quec_start_timer(self):
def get_post_res(self):
current_settings = settings.get()
self.quec_timer.start(current_settings['sys']['quecIot_timeout'] * 1000, 2, self.quec_timer_callback)
res = self.post_result_wait_queue.get()
self.quec_timer.stop()
return res
def quec_timer_callback(self):
current_settings = settings.get()
@ -88,9 +91,7 @@ class QuecThing(object):
v = {object_model_code.get(ik) if object_model_code.get(ik) else ik: iv for ik, iv in v.items()}
phymodelReport_res = quecIot.phymodelReport(1, {object_model_code.get(k): v})
if phymodelReport_res:
self.quec_start_timer()
res = self.post_result_wait_queue.get()
self.quec_timer.stop()
res = self.get_post_res()
if res:
v = {}
continue
@ -105,17 +106,13 @@ class QuecThing(object):
elif data_type == DATA_LOCA_GPS:
locReportOutside_res = quecIot.locReportOutside(data)
if locReportOutside_res:
self.quec_start_timer()
return self.post_result_wait_queue.get()
self.quec_timer.stop()
return self.get_post_res()
else:
return False
elif data_type == DATA_LOCA_NON_GPS:
locReportInside_res = quecIot.locReportInside(data)
if locReportInside_res:
self.quec_start_timer()
return self.post_result_wait_queue.get()
self.quec_timer.stop()
return self.get_post_res()
else:
return False
else:

View File

@ -328,38 +328,24 @@ class Remote(Singleton):
def clean_history(self):
uos.remove(self._history)
def _post_data(self, data_type, data):
if data_type == self.DATA_NON_LOCA or data_type == self.DATA_LOCA_NON_GPS or data_type == self.DATA_LOCA_GPS:
if not self.cloud.post_data(data_type, data):
self.add_history(data_type, data)
return False
else:
return True
else:
raise RemoteError('data_type %s is wrong.' % data_type)
def post_data(self, data_type, data):
'''
Data format to post:
'''
Data format to post:
--- non_loca ---
{
'switch': True,
'energy': 100
}
--- non_loca ---
{
'switch': True,
'energy': 100
}
--- loca_non_gps ---
(117.1138, 31.82279, 550)
--- loca_non_gps ---
(117.1138, 31.82279, 550)
--- loca_gps ---
['$GPRMCx,x,x,x', '$GPGGAx,x,x,x']
--- loca_gps ---
['$GPRMCx,x,x,x', '$GPGGAx,x,x,x']
'''
def post_data(self, data_type, data, bio=False):
if bio is False:
self.uplink_queue.put((data_type, data))
return True
else:
return self._post_data(data_type, data)
'''
self.uplink_queue.put((data_type, data))
def check_ota(self):
current_settings = settings.settings.get()