Files
onepilot/sunnypilot/sunnylink/registration_manager.py
github-actions[bot] 54e6124925 sunnypilot v2026.05.07-4485
version: sunnypilot v2026.001.000 (dev)
date: 2026-05-07T23:07:19
master commit: c28eb958740187620f2282023b8f1997cf90f583
2026-05-07 23:07:19 +00:00

36 lines
926 B
Python
Executable File

#!/usr/bin/env python3
import time
from openpilot.common.params import Params
from openpilot.common.realtime import Ratekeeper
from openpilot.common.swaglog import cloudlog
from cereal import log, messaging
from openpilot.sunnypilot.sunnylink.utils import register_sunnylink
NetworkType = log.DeviceState.NetworkType
def main():
"""The main method is expected to be called by the manager when the device boots up."""
try:
rk = Ratekeeper(.5)
sm = messaging.SubMaster(['deviceState'], poll='deviceState')
while True:
sm.update(1000)
if sm['deviceState'].networkType != NetworkType.none:
break
cloudlog.info(f"Waiting to become online... {time.monotonic()}")
rk.keep_time()
register_sunnylink()
except Exception:
cloudlog.exception("Sunnylink registration failed")
Params().put_bool("SunnylinkTempFault", True)
raise
if __name__ == "__main__":
main()