Firmware that connects to a Corne wireless keyboard via Bluetooth and presents itself as a USB HID keyboard for use with Deskhop KVM.
- BLE Central mode with HID over GATT Protocol (HOGP) client
- USB HID keyboard device (boot protocol, 8-byte reports)
- Passkey pairing support (displayed via USB serial console)
- Bond storage in flash for automatic reconnection
- Low latency: 7.5-15ms BLE interval, 1ms USB polling
# macOS dependencies
brew install cmake ninja gperf python3 ccache qemu dtc wget
# Install west (use pipx if pip3 fails due to externally-managed-environment)
pipx install west
# or: pip3 install west
# Initialize SDK workspace
mkdir ~/ncs && cd ~/ncs
west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.6.0
west update
west zephyr-export
# Zephyr SDK toolchain (for Apple Silicon use aarch64 variant)
cd ~
# For Intel Mac:
# wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5/zephyr-sdk-0.16.5_macos-x86_64.tar.xz
# For Apple Silicon:
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5/zephyr-sdk-0.16.5_macos-aarch64.tar.xz
tar xf zephyr-sdk-*.tar.xz
cd zephyr-sdk-*
./setup.sh
# Add to ~/.zshrc
export ZEPHYR_BASE=~/ncs/zephyrcd ~/ncs
west build -b xiao_ble /path/to/ble-to-hid- Double-tap the reset button on XIAO-nRF52840 to enter bootloader mode
- Copy
build/zephyr/zephyr.uf2to the USB drive that appears
- Connect XIAO to your computer via USB
- Open serial console:
screen /dev/tty.usbmodem* 115200 - Put your Corne keyboard in pairing mode
- When prompted, enter the displayed 6-digit passkey on the Corne
- Once paired, keystrokes from Corne will appear on the USB host
- Blinking: Scanning for BLE devices
- Solid: Connected to keyboard
- Brief flash: Keystroke forwarded
While connected to the serial console, you can use these commands:
c- Clear all Bluetooth bonds (requires confirmation withy)
ble-to-hid/
├── CMakeLists.txt # Build configuration
├── prj.conf # Kconfig settings
├── app.overlay # Devicetree overlay
└── src/
├── main.c # Entry point
├── usb_hid.c/h # USB HID keyboard
├── ble_central.c/h # BLE scanning/connection
├── hogp_client.c/h # HID over GATT client
├── pairing.c/h # Passkey authentication
└── hid_bridge.c/h # BLE->USB forwarding
Device not found: Ensure Corne is in pairing mode and close enough.
Pairing fails: Clear bonds on both devices and try again. On the dongle, press c then y in the serial console to clear bonds.
Keys stuck: Disconnect and reconnect USB to reset HID state.