From e02a9312eaa3d71fdfe6f74a1393daa4223cc429 Mon Sep 17 00:00:00 2001 From: mawei Date: Sun, 28 Jun 2026 15:46:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A0=8F=20WiFi=20=E4=B8=8B?= =?UTF-8?q?=E6=96=B9=E6=98=BE=E7=A4=BA=20IP=20=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- selfdrive/ui/layouts/sidebar.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/selfdrive/ui/layouts/sidebar.py b/selfdrive/ui/layouts/sidebar.py index 6f4b5035a..90f526179 100644 --- a/selfdrive/ui/layouts/sidebar.py +++ b/selfdrive/ui/layouts/sidebar.py @@ -1,4 +1,5 @@ import pyray as rl +import socket import time from dataclasses import dataclass from collections.abc import Callable @@ -105,6 +106,18 @@ class Sidebar(Widget): self._draw_network_indicator(rect) self._draw_metrics(rect) + def _get_ip_address(self) -> str: + """Get the device's local IP address.""" + try: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.settimeout(1) + s.connect(('10.0.0.1', 80)) + ip = s.getsockname()[0] + s.close() + return ip + except Exception: + return "" + def _update_state(self): sm = ui_state.sm if not sm.updated['deviceState']: @@ -210,6 +223,13 @@ class Sidebar(Widget): text_pos = rl.Vector2(rect.x + 58, text_y) rl.draw_text_ex(self._font_regular, tr(self._net_type), text_pos, FONT_SIZE, 0, Colors.WHITE) + # IP address below network type + ip = self._get_ip_address() + if ip: + ip_y = text_y + FONT_SIZE * FONT_SCALE + 8 + ip_pos = rl.Vector2(rect.x + 58, ip_y) + rl.draw_text_ex(self._font_regular, ip, ip_pos, 30, 0, Colors.WHITE_DIM) + def _draw_metrics(self, rect: rl.Rectangle): metrics = [(self._temp_status, 338), (self._panda_status, 496)] if not ui_state.dp_dev_disable_connect: