Better handling of missing lat/lon when GPS is starting up (#1323)

This commit is contained in:
Tim Wilkinson 2024-08-19 16:19:35 -07:00 committed by GitHub
parent b2d0b2980b
commit 4ce3a6c554
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 4 deletions

View File

@ -583,10 +583,8 @@ function hardware.gps_read_llt(gps, maxlines)
local j = gps_read(s) local j = gps_read(s)
if j.class == "TPV" then if j.class == "TPV" then
info.time = j.time:gsub("T", " "):gsub(".000Z", "") info.time = j.time:gsub("T", " "):gsub(".000Z", "")
if j.lat then if j.lat and j.lon then
info.lat = tonumber(string.format("%.5f", j.lat)) info.lat = tonumber(string.format("%.5f", j.lat))
end
if j.lon then
info.lon = tonumber(string.format("%.5f", j.lon)) info.lon = tonumber(string.format("%.5f", j.lon))
end end
break break

View File

@ -81,7 +81,7 @@ function app.run()
end end
-- Set location if significantly changed -- Set location if significantly changed
if c:get("aredn", "@location[0]", "gps_enable") == "1" then if c:get("aredn", "@location[0]", "gps_enable") == "1" and j.lat and j.lon then
local clat = tonumber(c:get("aredn", "@location[0]", "lat") or 0) local clat = tonumber(c:get("aredn", "@location[0]", "lat") or 0)
local clon = tonumber(c:get("aredn", "@location[0]", "lon") or 0) local clon = tonumber(c:get("aredn", "@location[0]", "lon") or 0)
if math.abs(clat - j.lat) > CHANGEMARGIN or math.abs(clon - j.lon) > CHANGEMARGIN then if math.abs(clat - j.lat) > CHANGEMARGIN or math.abs(clon - j.lon) > CHANGEMARGIN then