diff --git a/common/params.cc b/common/params.cc index 203a275f1..77430ff73 100644 --- a/common/params.cc +++ b/common/params.cc @@ -217,6 +217,7 @@ std::unordered_map keys = { {"dp_nav_full_screen", PERSISTENT}, {"dp_alka", PERSISTENT}, {"dp_device_reset_conf", CLEAR_ON_MANAGER_START}, + {"dp_device_ip_addr", PERSISTENT}, }; } // namespace diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index 75b966c9a..1cedbb9cf 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -106,6 +106,11 @@ void Sidebar::updateState(const UIState &s) { pandaStatus = {{tr("GPS"), tr("SEARCH")}, warning_color}; } setProperty("pandaStatus", QVariant::fromValue(pandaStatus)); + // rick - update every 5 secs + if (sm.frame % UI_FREQ*5 == 0) { + QString ip_addr = QString::fromStdString(Params().get("dp_device_ip_addr")); + setProperty("ipAddr", ip_addr); + } } void Sidebar::paintEvent(QPaintEvent *event) { @@ -136,6 +141,12 @@ void Sidebar::paintEvent(QPaintEvent *event) { const QRect r = QRect(50, 247, 100, 50); p.drawText(r, Qt::AlignCenter, net_type); + // IP + p.setFont(InterFont(30)); + p.setPen(QColor(0xff, 0xff, 0xff)); + const QRect ip = QRect(40, 260, 230, 100); + p.drawText(ip, Qt::AlignCenter, ipAddr); + // metrics drawMetric(p, temp_status.first, temp_status.second, 338); drawMetric(p, panda_status.first, panda_status.second, 496); diff --git a/selfdrive/ui/qt/sidebar.h b/selfdrive/ui/qt/sidebar.h index f627aac81..0b818a640 100644 --- a/selfdrive/ui/qt/sidebar.h +++ b/selfdrive/ui/qt/sidebar.h @@ -17,6 +17,7 @@ class Sidebar : public QFrame { Q_PROPERTY(ItemStatus tempStatus MEMBER temp_status NOTIFY valueChanged); Q_PROPERTY(QString netType MEMBER net_type NOTIFY valueChanged); Q_PROPERTY(int netStrength MEMBER net_strength NOTIFY valueChanged); + Q_PROPERTY(QString ipAddr MEMBER ipAddr NOTIFY valueChanged); public: explicit Sidebar(QWidget* parent = 0); diff --git a/system/hardware/hardwared.py b/system/hardware/hardwared.py index e3a4c8171..4caff20d8 100755 --- a/system/hardware/hardwared.py +++ b/system/hardware/hardwared.py @@ -25,6 +25,8 @@ from openpilot.system.hardware.power_monitoring import PowerMonitoring from openpilot.system.hardware.fan_controller import TiciFanController from openpilot.system.version import terms_version, training_version +from openpilot.dp_ext.utils import get_ip_addr + ThermalStatus = log.DeviceState.ThermalStatus NetworkType = log.DeviceState.NetworkType NetworkStrength = log.DeviceState.NetworkStrength @@ -442,6 +444,12 @@ def hardware_thread(end_event, hw_queue) -> None: params.put_bool_nonblocking("NetworkMetered", msg.deviceState.networkMetered) + # rick - update IP every 10s + if count % int(10. / DT_HW) == 0: + ip = get_ip_addr() + ip = '' if ip is None else ip + params.put('dp_device_ip_addr', ip) + count += 1 should_start_prev = should_start diff --git a/system/manager/manager.py b/system/manager/manager.py index 3026f4f0d..12bab1dd1 100755 --- a/system/manager/manager.py +++ b/system/manager/manager.py @@ -49,6 +49,7 @@ def manager_init() -> None: ("dp_long_personality_btn", "0"), ("dp_nav_full_screen", "0"), ("dp_alka", "0"), + ("dp_device_ip_addr", ""), ] if not PC: default_params.append(("LastUpdateTime", datetime.datetime.now(datetime.UTC).replace(tzinfo=None).isoformat().encode('utf8')))