mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-07 06:32:08 +08:00
mici setup: get time immediately after internet (#37565)
* should be instant * guard on disconnect * just time fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import re
|
||||
import ssl
|
||||
import threading
|
||||
import time
|
||||
import urllib.request
|
||||
@@ -16,6 +17,7 @@ from openpilot.common.filter_simple import FirstOrderFilter
|
||||
from openpilot.system.hardware import HARDWARE, TICI
|
||||
from openpilot.common.realtime import config_realtime_process, set_core_affinity
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.common.time_helpers import system_time_valid
|
||||
from openpilot.common.utils import run_cmd
|
||||
from openpilot.system.ui.lib.application import gui_app, FontWeight
|
||||
from openpilot.system.ui.lib.wifi_manager import WifiManager
|
||||
@@ -55,6 +57,7 @@ class NetworkConnectivityMonitor:
|
||||
self.wifi_connected = threading.Event()
|
||||
self._should_check = should_check or (lambda: True)
|
||||
self._stop_event = threading.Event()
|
||||
self._last_timesyncd_restart = 0.0
|
||||
self._thread: threading.Thread | None = None
|
||||
|
||||
def start(self):
|
||||
@@ -82,6 +85,13 @@ class NetworkConnectivityMonitor:
|
||||
self.network_connected.set()
|
||||
if HARDWARE.get_network_type() == NetworkType.wifi:
|
||||
self.wifi_connected.set()
|
||||
except urllib.error.URLError as e:
|
||||
if (isinstance(e.reason, ssl.SSLCertVerificationError) and
|
||||
not system_time_valid() and
|
||||
time.monotonic() - self._last_timesyncd_restart > 5):
|
||||
self._last_timesyncd_restart = time.monotonic()
|
||||
run_cmd(["sudo", "systemctl", "restart", "systemd-timesyncd"])
|
||||
self.reset()
|
||||
except Exception:
|
||||
self.reset()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user