10000 GitHub - anisehid/hid-proxy-for-ble-keyboard: Hid proxy for ble keyboards, based on esp32c3 and ch9329/ch9328
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

anisehid/hid-proxy-for-ble-keyboard

Repository files navigation

A hid proxy using ESP32C3 and CH9329/CH9328. ESP32C3 responds for BLE hosting, LED controling and storing connected bluetooth device addr with nvs_flash. And CH9329/CH9328 is used to simulate keyboard.

This was tested on following keyboards:

  • zmk based keyboards

Features

  • hid proxy for bluetooth keyboard: Scan and connect to BLE keyboards. The code is modified based on the official example: https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_hid_host

    Which device will be selected:

    1. UUID is 0x1812 while parsing with ESP_BLE_AD_TYPE_16SRV_PART
    2. Apprearence equals to ESP_BLE_APPEARANCE_HID_KEYBOARD (0x03C1)
    3. The first scanned device will be selected
    4. No authentication is required
  • Remember connected keyboard: Use nvs_flash to store one bluetooth device address. Once this is set, hid host will skip other devices.
  • LED signals to illustrate connection mode. There are three LED mode:
    • Rapid blink mode: Scan for new device.
    • Slow blink mode: Scan for known device.
    • Off: Connected.
  • Relay the keyboard’s input to CH9328/CH9329

Build and flash

Install esp idf: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html

set target to esp32c3

idf.py set-target esp32c3

Then, build and flash to your hid proxy using serial port dev/ttyUSB0. With monitor, you can start monitor after flashing, use Ctrl-] to stop monitor and release the port.

idf.py -p /dev/ttyUSB0 -b 115200 flash monitor

Usage

  • Connect to new device: if no device is stored, esp32c3 will start scanning available keyboards, and led will turn into rapid blink mode. The scanning may take a few seconds. After connecting to the first scanned device, led will tuen into off mode. And the connected device is stored.
  • Connect to known device: If no device is connected and there exists a bluetooth device address (esp_bd_addr_t) stored in esp32c3’s nvs_flash. The LED will try scan this recorded device, and tune led into slow blink mode.
  • Erase known device: Press the boot button (IO9) for at lease one second, until the led turns into rapid blink mode.

Known issues

  • Crash if the opened keyboard is already connected to another hid_proxy.
  • LED mode change delay after pressing the boot button to erase.

Todos

  • Storing multiple devices and swithing with an extra button
  • Support ble mouse with ch9329
  • Refactor the code to make it more robust
  • start a web server for keyboad connecting, this is useful when you have multiple keyboards or need authentication

About

Hid proxy for ble keyboards, based on esp32c3 and ch9329/ch9328

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0