How teganburns/arduinokeybridge works
Project Type and Purpose
• ArduinoKeyBridge is an embedded IoT firmware project written in C++/Arduino for the Arduino Uno R4 Wi-Fi.
• It turns a standard USB keyboard into a standalone, Wi-Fi–enabled input device with custom key mappings, remote command execution, status LEDs, and logging—no host PC software required.
File Structure
• Top-level sketch:
• ArduinoKeyBridge.ino – the entry point, setup() and loop().
• Modular C++ components:
• WiFiConnection.* – manages SSID, sockets, HTTP or raw‐TCP interactions.
• JsonHandler.* – serializes/deserializes command payloads (JSON).
• CustomKeyboardParser.* – interprets raw HID key codes & maps them to actions.
• CustomKeyboardCommands.* – defines/executes user‐configured macros or operations.
• MinimalKeyboard.* and Magic_Keyboard_KeyMap.h – USB Host HID interface and vendor‐specific key maps.
• ArduinoKeyBridgeLogger.* – logs events to serial output or over network.
• ArduinoKeyBridgeNeoPixel.* – drives status LEDs for feedback.
• Utility script:
• upload_monitor.sh – automates firmware upload and serial monitoring.
Extract Insights from README
• Key features: customizable key functions, standalone operation, Wi-Fi integration.
• Hardware dependencies: USB HID Shield, Magic Keyboard, Arduino Uno R4 Wi-Fi.
• Use cases emphasize remote control, macros, IoT integration, accessibility.
Main Components
a. Hardware Layer
• USB Keyboard → SparkFun HID Keyboard Shield → Arduino Uno R4 Wi-Fi MCU
• NeoPixel Ring (or LED array) connected to a digital pin
• On-board Wi-Fi radio & antenna
b. Firmware Modules (Software Layer)
1. HID Interface (MinimalKeyboard & Magic_Keyboard_KeyMap)
2. Key Parsing (CustomKeyboardParser)
3. Command Execution (CustomKeyboardCommands)
4. Wi-Fi Stack & Networking (WiFiConnection)
5. Payload Handling (JsonHandler)
6. Status & Logging (ArduinoKeyBridgeNeoPixel & Logger)
c. External Services
• Remote Control Client (e.g., web UI or mobile app) – communicates via TCP/HTTP
• Optional backend or IoT platform receiving telemetry
Relationships & Data Flow
• USB Keyboard presses → HID Interface → Parser → Command Dispatcher
• Dispatcher may:
• Invoke local routines (macros, LED patterns, GPIO)
• Send/receive JSON over Wi-Fi via WiFiConnection
• Output logs via Serial or network to external monitoring
• LED module subscribes to status events (e.g., “connected,” “key pressed,” “error”).
• Logger records key events and network interactions.
Architectural Patterns & Design Principles
• Modular separation of concerns: each .cpp/.h pair is a single responsibility module.
• Event-driven workflow: parsing → dispatch → action.
• Layered approach: hardware abstraction (HID), business logic (commands), infrastructure (Wi-Fi, JSON).
• Extensibility: new commands or devices map into the existing parser/command modules.
Essential Elements
• Notes on protocols (USB HID, Wi-Fi—TCP or HTTP, JSON).
• Version of Arduino core or critical library dependencies if relevant.