Skip to content

Commit 0fef424

Browse files
committed
web: display notification on USB Power overload
This should make debuging mis-behaving USB devices easier. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
1 parent 4b29c2b commit 0fef424

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

web/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
ProgressNotification,
3838
LocatorNotification,
3939
OverTemperatureNotification,
40+
UsbOverloadNotification,
4041
} from "./TacComponents";
4142

4243
function Navigation() {
@@ -159,6 +160,7 @@ function Notifications() {
159160
<RebootNotification />
160161
<OverTemperatureNotification />
161162
<ProgressNotification />
163+
<UsbOverloadNotification />
162164
<UpdateNotification />
163165
<LocatorNotification />
164166
<IOBusFaultNotification />

web/src/TacComponents.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ enum RaucInstallStep {
8989
Done,
9090
}
9191

92+
enum UsbOverload {
93+
Total = "Total",
94+
Port1 = "Port1",
95+
Port2 = "Port2",
96+
Port3 = "Port3",
97+
}
98+
9299
type Duration = {
93100
secs: number;
94101
nanos: number;
@@ -520,3 +527,39 @@ export function OverTemperatureNotification() {
520527
</Alert>
521528
);
522529
}
530+
531+
export function UsbOverloadNotification() {
532+
const overload = useMqttSubscription<UsbOverload | null>(
533+
"/v1/usb/host/overload",
534+
);
535+
536+
let header = "One of the USB host ports is overloaded";
537+
let detail = "";
538+
539+
switch (overload) {
540+
case UsbOverload.Total:
541+
header = "The USB host ports are overloaded";
542+
detail = "devices";
543+
break;
544+
case UsbOverload.Port1:
545+
detail = "the device from port 1";
546+
break;
547+
case UsbOverload.Port2:
548+
detail = "the device from port 2";
549+
break;
550+
case UsbOverload.Port3:
551+
detail = "the device from port 3";
552+
break;
553+
}
554+
555+
return (
556+
<Alert
557+
statusIconAriaLabel="Warning"
558+
type="warning"
559+
visible={overload !== null}
560+
header={header}
561+
>
562+
Disconnect {detail} or use a powered hub to resolve this issue.
563+
</Alert>
564+
);
565+
}

0 commit comments

Comments
 (0)