From 4fd0ae8002e588914eab5c55266c380214ad7664 Mon Sep 17 00:00:00 2001 From: KGN Date: Fri, 6 Dec 2024 15:15:52 -0500 Subject: [PATCH] Baud updates --- src/app/src/features/Connection/components/PortListings.tsx | 5 ++++- src/app/src/features/Connection/index.tsx | 5 +++-- src/app/src/lib/storeUpdate.ts | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/src/features/Connection/components/PortListings.tsx b/src/app/src/features/Connection/components/PortListings.tsx index b46304024..7152185fb 100644 --- a/src/app/src/features/Connection/components/PortListings.tsx +++ b/src/app/src/features/Connection/components/PortListings.tsx @@ -17,6 +17,7 @@ function truncatePortName(port: string): string { export function PortListings(props: PortListingsProps): JSX.Element { const [ip, setIP] = useState('255.255.255.255'); + const [baud, setBaud] = useState(115200); useEffect(() => { const ip = store.get('widgets.connection.ip', []); @@ -26,8 +27,10 @@ export function PortListings(props: PortListingsProps): JSX.Element { store.on('change', () => { const ip = store.get('widgets.connection.ip', []); + const baudrate = store.get('widgets.connection.baudrate', 115200); const ipString = ip.join('.'); setIP(ipString); + setBaud(baudrate); }); return ( @@ -56,7 +59,7 @@ export function PortListings(props: PortListingsProps): JSX.Element { - USB at 115200 baud + USB at {baud} baud diff --git a/src/app/src/features/Connection/index.tsx b/src/app/src/features/Connection/index.tsx index cd4137199..1c97a340b 100644 --- a/src/app/src/features/Connection/index.tsx +++ b/src/app/src/features/Connection/index.tsx @@ -65,6 +65,7 @@ function Connection(props: ConnectionProps) { } const network = type === ConnectionType.ETHERNET; + const baud = Number(store.get('widgets.connection.baudrate')); // workflow - set element to connecting state, attempt to connect, and use callback to update state on end setConnectionState(ConnectionState.CONNECTING); @@ -75,7 +76,7 @@ function Connection(props: ConnectionProps) { port, // firmware, { - baudrate: 115200, + baudrate: baud, network, }, (err: string) => { @@ -90,7 +91,7 @@ function Connection(props: ConnectionProps) { ); connectionConfig.set('port', port); - connectionConfig.set('baudrate', 115200); + connectionConfig.set('baudrate', baud); } function onDisconnectClick() { diff --git a/src/app/src/lib/storeUpdate.ts b/src/app/src/lib/storeUpdate.ts index 0f5af5407..c478d04e4 100644 --- a/src/app/src/lib/storeUpdate.ts +++ b/src/app/src/lib/storeUpdate.ts @@ -1,6 +1,7 @@ import store from '../store'; import defaultState from '../store/defaultState'; import api from '../api'; +import { toast } from 'app/lib/toaster'; export const restoreDefault = async (): Promise => { await api.events.clearAll(); @@ -13,11 +14,12 @@ const restoreSettings = (state: object, isSync?: boolean): void => { // if this is being called for importing settings, need to reload // if sync, no reload needed - if (!isSync) { + /*if (!isSync) { setTimeout(() => { window.location.reload(); }, 250); - } + }*/ + toast.success('Settings restored'); }; export const storeUpdate = async (