From 7d39e726b41d8a41246bc53d15df0e1144e51a15 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Mon, 2 Mar 2026 20:19:49 -0800 Subject: [PATCH] Local serving optimizations and Windows docs updates --- README.md | 21 +++++++++++++++++++++ frontend/src/useWebSocket.ts | 6 +----- frontend/vite.config.ts | 2 ++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index db7b70a..0123744 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,12 @@ ls /dev/ttyUSB* /dev/ttyACM* ####### ls /dev/cu.usbserial-* /dev/cu.usbmodem* +########### +# Windows +########### +# In PowerShell: +Get-CimInstance Win32_SerialPort | Select-Object DeviceID, Caption + ###### # WSL2 ###### @@ -88,6 +94,12 @@ MESHCORE_TCP_HOST=192.168.1.100 MESHCORE_TCP_PORT=4000 uv run uvicorn app.main:a MESHCORE_BLE_ADDRESS=AA:BB:CC:DD:EE:FF MESHCORE_BLE_PIN=123456 uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 ``` +On Windows (PowerShell), set environment variables as a separate statement: +```powershell +$env:MESHCORE_SERIAL_PORT="COM8" # or your COM port +uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 +``` + Access at http://localhost:8000 > **Note:** WebGPU cracking requires HTTPS when not on localhost. See the HTTPS section under Additional Setup. @@ -149,6 +161,15 @@ uv run uvicorn app.main:app --reload # autodetects serial port MESHCORE_SERIAL_PORT=/dev/ttyUSB0 uv run uvicorn app.main:app --reload ``` +On Windows (PowerShell): +```powershell +uv sync +$env:MESHCORE_SERIAL_PORT="COM8" # or your COM port +uv run uvicorn app.main:app --reload +``` + +> **Windows note:** I've seen an intermittent startup issue like `"Received empty packet: index out of range"` with failed contact sync. I can't figure out why this happens. The issue typically resolves on restart. If you can figure out why this happens, I will buy you a virtual or iRL six pack if you're in the PNW. As a former always-windows-girlie before embracing WSL2, I despise second-classing M$FT users, but I'm just stuck with this one. + ### Frontend ```bash diff --git a/frontend/src/useWebSocket.ts b/frontend/src/useWebSocket.ts index 6477a26..c1d6505 100644 --- a/frontend/src/useWebSocket.ts +++ b/frontend/src/useWebSocket.ts @@ -49,11 +49,7 @@ export function useWebSocket(options: UseWebSocketOptions) { const connect = useCallback(() => { // Determine WebSocket URL based on current location const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - // In development, connect directly to backend; in production, use same host - const isDev = window.location.port === '5173'; - const wsUrl = isDev - ? `ws://localhost:8000/api/ws` - : `${protocol}//${window.location.host}/api/ws`; + const wsUrl = `${protocol}//${window.location.host}/api/ws`; const ws = new WebSocket(wsUrl); diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 10b4892..08e36f9 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -29,10 +29,12 @@ export default defineConfig({ sourcemap: true, }, server: { + host: true, proxy: { '/api': { target: 'http://localhost:8000', changeOrigin: true, + ws: true, }, }, watch: {