wip
This commit is contained in:
@@ -86,6 +86,13 @@ measurementStatusGlonassFields = {
|
||||
"glonassTimeMarkValid": 17
|
||||
}
|
||||
|
||||
|
||||
# GPS tracking settings
|
||||
last_reported_latitude = None
|
||||
last_reported_longitude = None
|
||||
last_reported_time = time.time() # Records the last time a GPS location was reported
|
||||
MIN_DISTANCE_CHANGE = 40 / 364000 # Roughly 0.00011 degrees
|
||||
|
||||
@retry(attempts=10, delay=1.0)
|
||||
def try_setup_logs(diag, logs):
|
||||
return setup_logs(diag, logs)
|
||||
@@ -362,6 +369,32 @@ def main() -> NoReturn:
|
||||
stop_download_event.set()
|
||||
pm.send('gpsLocation', msg)
|
||||
|
||||
# Custom GPS tracking by brian
|
||||
current_time = time.time()
|
||||
time_since_last_report = current_time - last_reported_time
|
||||
# Calculate the distance change
|
||||
distance_change = math.sqrt((gps.latitude - (last_reported_latitude or 0))**2 +
|
||||
(gps.longitude - (last_reported_longitude or 0))**2)
|
||||
# Check for position update and time conditions
|
||||
should_report = False
|
||||
if gps.speed < 2:
|
||||
if time_since_last_report >= 1 and distance_change >= MIN_DISTANCE_CHANGE:
|
||||
should_report = True
|
||||
else:
|
||||
if time_since_last_report >= 30 and distance_change >= MIN_DISTANCE_CHANGE:
|
||||
should_report = True
|
||||
# Execute reporting if conditions are met
|
||||
if should_report:
|
||||
if os.path.exists("/data/brian/gps_tracking.sh"):
|
||||
# Update the last reported time and location
|
||||
last_reported_time = current_time
|
||||
last_reported_latitude = gps.latitude
|
||||
last_reported_longitude = gps.longitude
|
||||
|
||||
# Call the script
|
||||
subprocess.run(["/data/brian/gps_tracking.sh", gps.latitude, gps.longitude, gps.speed], check=True)
|
||||
|
||||
|
||||
elif log_type == LOG_GNSS_OEMDRE_SVPOLY_REPORT:
|
||||
msg = messaging.new_message('qcomGnss', valid=True)
|
||||
dat = unpack_svpoly(log_payload)
|
||||
|
||||
Reference in New Issue
Block a user