import { Button } from "@components/Button"; import { LuTerminal } from "react-icons/lu"; import Card from "@components/Card"; import { SectionHeader } from "@components/SectionHeader"; import { SelectMenuBasic } from "../SelectMenuBasic"; import { useJsonRpc } from "@/hooks/useJsonRpc"; import { useEffect, useState } from "react"; import notifications from "@/notifications"; import { useUiStore } from "@/hooks/stores"; interface SerialSettings { baudRate: string; dataBits: string; stopBits: string; parity: string; } export function SerialConsole() { const [send] = useJsonRpc(); const [settings, setSettings] = useState({ baudRate: "9600", dataBits: "8", stopBits: "1", parity: "none", }); useEffect(() => { send("getSerialSettings", {}, resp => { if ("error" in resp) { notifications.error( `Failed to get serial settings: ${resp.error.data || "Unknown error"}`, ); return; } setSettings(resp.result as SerialSettings); }); }, [send]); const handleSettingChange = (setting: keyof SerialSettings, value: string) => { const newSettings = { ...settings, [setting]: value }; send("setSerialSettings", { settings: newSettings }, resp => { if ("error" in resp) { notifications.error( `Failed to update serial settings: ${resp.error.data || "Unknown error"}`, ); return; } setSettings(newSettings); }); }; const setTerminalType = useUiStore(state => state.setTerminalType); return (
{/* Open Console Button */}

{/* Settings */}
handleSettingChange("baudRate", e.target.value)} /> handleSettingChange("dataBits", e.target.value)} /> handleSettingChange("stopBits", e.target.value)} /> handleSettingChange("parity", e.target.value)} />
); }