import { useDevice } from "@core/stores"; import type { Protobuf } from "@meshtastic/core"; import { numberToHexUnpadded } from "@noble/curves/abstract/utils"; import { useTranslation } from "react-i18next"; type NodeUser = Pick; export interface TraceRouteProps { from: NodeUser; to: NodeUser; route: Array; routeBack?: Array; snrTowards?: Array; snrBack?: Array; } interface RoutePathProps { title: string; from: NodeUser; to: NodeUser; path: number[]; snr?: number[]; } const RoutePath = ({ title, from, to, path, snr }: RoutePathProps) => { const { getNode } = useDevice(); const { t } = useTranslation(); return (

{title}

{from?.user?.longName}

↓ {snr?.[0] ?? t("unknown.num")} {t("unit.dbm")}

{path.map((hop, i) => (

{getNode(hop)?.user?.longName ?? `${t("unknown.longName")} (!${numberToHexUnpadded(hop)})`}

↓ {snr?.[i + 1] ?? t("unknown.num")} {t("unit.dbm")}

))}

{to?.user?.longName}

); }; export const TraceRoute = ({ from, to, route, routeBack, snrTowards, snrBack, }: TraceRouteProps) => { const { t } = useTranslation("dialog"); return (
{routeBack && routeBack.length > 0 && ( )}
); };