Skip to content

Commit

Permalink
Baud updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kglovern committed Dec 6, 2024
1 parent cea0ec8 commit 4fd0ae8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/app/src/features/Connection/components/PortListings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function truncatePortName(port: string): string {

export function PortListings(props: PortListingsProps): JSX.Element {
const [ip, setIP] = useState<string>('255.255.255.255');
const [baud, setBaud] = useState(115200);

useEffect(() => {
const ip = store.get('widgets.connection.ip', []);
Expand All @@ -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 (
Expand Down Expand Up @@ -56,7 +59,7 @@ export function PortListings(props: PortListingsProps): JSX.Element {
</Tooltip>
</span>
<span className="text-sm text-gray-600 font-normal">
USB at 115200 baud
USB at {baud} baud
</span>
</div>
</button>
Expand Down
5 changes: 3 additions & 2 deletions src/app/src/features/Connection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -75,7 +76,7 @@ function Connection(props: ConnectionProps) {
port,
// firmware,
{
baudrate: 115200,
baudrate: baud,
network,
},
(err: string) => {
Expand All @@ -90,7 +91,7 @@ function Connection(props: ConnectionProps) {
);

connectionConfig.set('port', port);
connectionConfig.set('baudrate', 115200);
connectionConfig.set('baudrate', baud);
}

function onDisconnectClick() {
Expand Down
6 changes: 4 additions & 2 deletions src/app/src/lib/storeUpdate.ts
Original file line number Diff line number Diff line change
@@ -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<void> => {
await api.events.clearAll();
Expand All @@ -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 (
Expand Down

0 comments on commit 4fd0ae8

Please sign in to comment.