From 0fef4248f5fdea8ed63dfa2d231f6db4066e469d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Wed, 30 Aug 2023 15:46:02 +0200 Subject: [PATCH] web: display notification on USB Power overload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should make debuging mis-behaving USB devices easier. Signed-off-by: Leonard Göhrs --- web/src/App.tsx | 2 ++ web/src/TacComponents.tsx | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/web/src/App.tsx b/web/src/App.tsx index ddaefb97..d04c7831 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -37,6 +37,7 @@ import { ProgressNotification, LocatorNotification, OverTemperatureNotification, + UsbOverloadNotification, } from "./TacComponents"; function Navigation() { @@ -159,6 +160,7 @@ function Notifications() { + diff --git a/web/src/TacComponents.tsx b/web/src/TacComponents.tsx index 774fa48a..294bf233 100644 --- a/web/src/TacComponents.tsx +++ b/web/src/TacComponents.tsx @@ -89,6 +89,13 @@ enum RaucInstallStep { Done, } +enum UsbOverload { + Total = "Total", + Port1 = "Port1", + Port2 = "Port2", + Port3 = "Port3", +} + type Duration = { secs: number; nanos: number; @@ -520,3 +527,39 @@ export function OverTemperatureNotification() { ); } + +export function UsbOverloadNotification() { + const overload = useMqttSubscription( + "/v1/usb/host/overload", + ); + + let header = "One of the USB host ports is overloaded"; + let detail = ""; + + switch (overload) { + case UsbOverload.Total: + header = "The USB host ports are overloaded"; + detail = "devices"; + break; + case UsbOverload.Port1: + detail = "the device from port 1"; + break; + case UsbOverload.Port2: + detail = "the device from port 2"; + break; + case UsbOverload.Port3: + detail = "the device from port 3"; + break; + } + + return ( + + Disconnect {detail} or use a powered hub to resolve this issue. + + ); +}