Add offline and ntfy alerts
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
+7
-1
@@ -27,6 +27,7 @@ PWRKEY_HOLD_SECONDS = 4 # matches Waveshare's reference script
|
||||
|
||||
LocationX = None
|
||||
LocationY = None
|
||||
last_fix_at = None
|
||||
|
||||
_serial_lock = Lock()
|
||||
_serial = None
|
||||
@@ -148,7 +149,7 @@ def _parse_cgnsinf(resp):
|
||||
|
||||
|
||||
def _poll_loop():
|
||||
global LocationX, LocationY
|
||||
global LocationX, LocationY, last_fix_at
|
||||
try:
|
||||
with _serial_lock:
|
||||
if _ensure_module_powered():
|
||||
@@ -168,11 +169,16 @@ def _poll_loop():
|
||||
if fix:
|
||||
LocationX = fix["lat"]
|
||||
LocationY = fix["lon"]
|
||||
last_fix_at = time.monotonic()
|
||||
socketio.emit("gps_location", [LocationX, LocationY])
|
||||
|
||||
time.sleep(POLL_INTERVAL)
|
||||
|
||||
|
||||
def get_fix_age():
|
||||
return None if last_fix_at is None else time.monotonic() - last_fix_at
|
||||
|
||||
|
||||
def start_gps():
|
||||
"""Start the background thread that continuously polls the SIM868 for a GNSS fix."""
|
||||
global _gps_thread
|
||||
|
||||
Reference in New Issue
Block a user