3.0 KiB
3.0 KiB
NFC Network Client, Global Input Capture and Smart Connect
Date: 2025-12-24 Project: moonlight-drive-in Status: resolved Tags: nfc, network-client, tkinter, pynput, threading, launcher, windows
Context
NFC readers act as keyboards, so scanning only worked when the player window had focus, and it tied the reader to the player PC. Jess wanted a remote NFC client that can run on another machine, send scans to the player over the network, and "just connect" when launched. Work ran 2025-12-22 to 2025-12-24: a GUI client (v1.1.0 bug-fix release), a CLI client, launchers, then global input capture and a smart-connect launcher.
Key Decisions
- Network client instead of local keyboard input — the reader can live anywhere on the LAN/VPN and send IDs to the player's web API.
- Global input capture with
pynput— scans are captured regardless of which window has focus. - Thread-safe Tkinter updates — background threads schedule UI changes with
root.after(0, ...); direct updates caused "main thread is not in main loop" errors. - Smart connect with verification — try multiple resolution methods (DNS, Tailscale MagicDNS, mDNS) and verify the player's HTTP server responds before connecting; fall back to the fixed LAN IP
10.0.0.134. - Simplify to a CLI auto-start with a 5-second timer — the final launcher starts the interactive CLI client automatically after 5 s unless the user intervenes, which proved more reliable than the GUI auto-connect.
- ASCII-safe console output (
[WEB],[CTRL],[VIDEO]) instead of emoji — emoji corrupted the Windows console. - Keep compatibility with
NFCNetworkClientv1.1.0 — the launcher passes the Tkrootcorrectly rather than changing the client API.
Technical Details
- Player web UI/API on port 8547 (LAN
10.0.0.134, Tailscale<redacted>). clients/nfc_network_client.py— GUI remote control;clients/nfc_autoconnect.py— fixed auto-connect client;clients/nfc_cli_client.py— CLI client;clients/network_test.py— connectivity diagnostics.- Launchers:
START_DRIVEIN.bat,START_CLIENT.bat,start_nfc_client.bat,connect_drivein_simple.bat,test_network.bat. clients/client_requirements.txt— includespynput.
Code Changes
clients/— new client system (GUI, CLI, auto-connect, diagnostics, launchers, docs: README, QUICKSTART, CHANGELOG, UPDATE_GUIDE, SMART_CONNECT_FIX, IMPLEMENTATION_SUMMARY).- Global input capture fix — NFC scans work regardless of focus (
40f23b0). - Smart connect v2.2.0 — HTTP verification + fallback IP (
ca36215). connect_drivein_simple.bat— 5-second auto-start of the CLI client (5ad870e).
Open Questions / Next Steps
- LEGO Dimensions portal is the planned replacement for the single-tag ACR122 reader (see
lego-dimensions-reader).
Artifacts
5ad870e— Simplify to auto-start Interactive CLI with 5-second timerca36215— Fix smart connect v2.2.040f23b0— Fix global input capturee90b8da— FIXED auto-connect client - resolves GUI initialization error