bluetooth-2-usb


Namebluetooth-2-usb JSON
Version 0.8.0 PyPI version JSON
download
home_page
SummaryConvert a Raspberry Pi into a HID relay translating Bluetooth keyboard and mouse input to USB.
upload_time2023-12-17 12:15:44
maintainer
docs_urlNone
author
requires_python>=3.11
licenseMIT
keywords adapter proxy relay bluetooth usb hid human interface device keyboard mouse consumer keycode keypadhardware raspberry evdev
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- omit in toc -->
# Bluetooth to USB

![Connection overview](assets/overview.png)

<!-- omit in toc -->
## Table of Contents

- [1. Introduction](#1-introduction)
- [2. Features](#2-features)
- [3. Requirements](#3-requirements)
- [4. Installation](#4-installation)
  - [4.1. Prerequisites](#41-prerequisites)
  - [4.2. Setup](#42-setup)
- [5. Usage](#5-usage)
  - [5.1. Connection to target device / host](#51-connection-to-target-device--host)
    - [5.1.1. Raspberry Pi 4 Model B](#511-raspberry-pi-4-model-b)
    - [5.1.2. Raspberry Pi Zero (2) W(H)](#512-raspberry-pi-zero-2-wh)
  - [5.2. Command-line arguments](#52-command-line-arguments)
  - [5.3. Consuming the API from your Python code](#53-consuming-the-api-from-your-python-code)
- [6. Updating](#6-updating)
- [7. Uninstallation](#7-uninstallation)
- [8. Troubleshooting](#8-troubleshooting)
  - [8.1. The Pi keeps rebooting or crashes randomly](#81-the-pi-keeps-rebooting-or-crashes-randomly)
  - [8.2. The installation was successful, but I don't see any output on the target device](#82-the-installation-was-successful-but-i-dont-see-any-output-on-the-target-device)
  - [8.3. In bluetoothctl, my device is constantly switching on/off](#83-in-bluetoothctl-my-device-is-constantly-switching-onoff)
  - [8.4. I have a different issue](#84-i-have-a-different-issue)
  - [8.5. Everything is working, but can it help me with Bitcoin mining?](#85-everything-is-working-but-can-it-help-me-with-bitcoin-mining)
- [9. Bonus points](#9-bonus-points)
- [10. Contributing](#10-contributing)
- [11. License](#11-license)
- [12. Acknowledgments](#12-acknowledgments)

## 1. Introduction

Convert a Raspberry Pi into a HID relay that translates Bluetooth keyboard and mouse input to USB. Minimal configuration. Zero hassle.

The issue with Bluetooth devices is that you usually can't use them to:
- wake up sleeping devices,
- access the BIOS or OS select menu (e.g., GRUB),
- access devices without Bluetooth interface (e.g., devices in a restricted environment or most KVM switches).

Sounds familiar? Congratulations! **You just found the solution!**

Linux's gadget mode allows a Raspberry Pi to act as USB HID (Human Interface Device). Therefore, from the host's perspective, it appears like a regular USB keyboard or mouse. You may think of your Pi as a multi-device Bluetooth dongle.

## 2. Features

- Simple installation and highly automated setup
- Supports multiple input devices (currently keyboard and mouse - more than one of each kind simultaneously)
- Supports [146 multimedia keys](https://github.com/quaxalber/bluetooth_2_usb/blob/8b1c5f8097bbdedfe4cef46e07686a1059ea2979/lib/evdev_adapter.py#L142) (e.g., mute, volume up/down, launch browser, etc.)
- Auto-discovery feature for input devices
- Auto-reconnect feature for input devices (power off, energy saving mode, out of range, etc.)
- Robust error handling and logging
- Installation as a systemd service
- Reliable concurrency using state-of-the-art [TaskGroups](https://docs.python.org/3/library/asyncio-task.html#task-groups)
- Clean and actively maintained code base

## 3. Requirements

- A Raspberry Pi with Bluetooth and [USB OTG support](https://en.wikipedia.org/wiki/USB_On-The-Go) required for [USB gadgets](https://www.kernel.org/doc/html/latest/driver-api/usb/gadget.html) in so-called device mode. Supported models include:
  - **Raspberry Pi Zero W(H)**: Includes Bluetooth 4.1 and supports USB OTG with the lowest price tag.
  - **Raspberry Pi Zero 2 W**: Similar to the Raspberry Pi Zero W, it has Bluetooth 4.1 and USB OTG support while providing additional processing power.
  - **Raspberry Pi 4 Model B**: Offers Bluetooth 5.0 and USB-C OTG support for device mode, providing the best performance (that is until the Pi 5 is available).
- Linux OS with systemd support (e.g., [Raspberry Pi OS](https://www.raspberrypi.com/software/), recommended).
- Python 3.11 for using [TaskGroups](https://docs.python.org/3/library/asyncio-task.html#task-groups).

> [!NOTE]
> Raspberry Pi 3 Models feature Bluetooth 4.2 but no native USB gadget mode support. Earlier models like Raspberry Pi 1 and 2 do not support Bluetooth natively and have no USB gadget mode support.

> [!NOTE]
> The latest version of Raspberry Pi OS, based on Debian Bookworm, supports Python 3.11 through the official package repositories. For older versions, you may [build it from source](https://github.com/quaxalber/bluetooth_2_usb/blob/main/scripts/build_python_3.11.sh). Note that building may take anything between a few minutes (Pi 4B) and more than an hour (Pi 0W).

## 4. Installation

Follow these steps to install and configure the project:

### 4.1. Prerequisites

1. Install an OS on your Raspberry Pi (e.g., using [Pi Imager](https://youtu.be/ntaXWS8Lk34))
  
2. Connect to a network via Ethernet cable or [Wi-Fi](https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-networking). Make sure this network has Internet access.
  
3. (*optional, recommended*) Enable [SSH](https://www.raspberrypi.com/documentation/computers/remote-access.html#ssh), if you intend to access the Pi remotely.

> [!NOTE]
> These settings above may be configured [during imaging](https://www.raspberrypi.com/documentation/computers/getting-started.html#advanced-options) (recommended), [on first boot](https://www.raspberrypi.com/documentation/computers/getting-started.html#configuration-on-first-boot) or [afterwards](https://www.raspberrypi.com/documentation/computers/configuration.html).
  
4. Connect to the Pi and make sure `git` is installed:
  
   ```console
   sudo apt update && sudo apt upgrade -y && sudo apt install -y git
   ```

5. Pair and trust any Bluetooth devices you wish to relay, either via GUI or via CLI:
  
   ```console
   bluetoothctl
   scan on
   ```

   ... wait for your devices to show up and note their MAC addresses (you may also type the first characters and hit `TAB` for auto-completion in the following commands) ...

   ```console
   trust A1:B2:C3:D4:E5:F6
   pair A1:B2:C3:D4:E5:F6
   connect A1:B2:C3:D4:E5:F6
   ```

> [!NOTE]
> Replace `A1:B2:C3:D4:E5:F6` by your input device's Bluetooth MAC address

### 4.2. Setup

6. On the Pi, clone the repository to your home directory:
  
   ```console
   cd ~ && git clone https://github.com/quaxalber/bluetooth_2_usb.git
   ```

7. Run the installation script as root:
   
   ```console
   sudo ~/bluetooth_2_usb/scripts/install.sh
   ```

8.  Reboot:
 
    ```console
    sudo reboot
    ``` 

9.  Verify that the service is running:
   
    ```console
    service bluetooth_2_usb status
    ```

    It should look something like this and say `Active: active (running)`:

    ```console
    user@pi0w:~ $ service bluetooth_2_usb status
    ● bluetooth_2_usb.service - Bluetooth to USB HID relay
        Loaded: loaded (/etc/systemd/system/bluetooth_2_usb.service; enabled; preset: enabled)
        Active: active (running) since Wed 2023-12-13 10:33:00 CET; 44min ago
      Main PID: 5865 (bash)
          Tasks: 4 (limit: 389)
            CPU: 2min 49.448s
        CGroup: /system.slice/bluetooth_2_usb.service
                ├─5865 bash /usr/bin/bluetooth_2_usb --auto_discover --grab_devices
                └─5869 python3.11 /home/user/bluetooth_2_usb/bluetooth_2_usb.py --auto_discover --grab_devices

    Dec 13 10:33:00 pi0w systemd[1]: Started bluetooth_2_usb.service - Bluetooth to USB HID relay.
    Dec 13 10:33:06 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:06 [INFO] Launching Bluetooth 2 USB v0.8.0
    Dec 13 10:33:06 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:06 [INFO] Discovering input devices...
    Dec 13 10:33:09 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:09 [INFO] Activated relay for device /dev/input/event2, name "AceRK Mouse", phys "0a:1b:2c:3d:4e:5f"
    Dec 13 10:33:09 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:09 [INFO] Activated relay for device /dev/input/event1, name "AceRK Keyboard", phys "0a:1b:2c:3d:4e:5f"
    Dec 13 10:33:09 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:09 [INFO] Activated relay for device /dev/input/event0, name "vc4-hdmi", phys "vc4-hdmi/input0"
    ```

> [!NOTE]
> Something seems off? Try yourself in [Troubleshooting](#8-troubleshooting)!
   
## 5. Usage

### 5.1. Connection to target device / host

#### 5.1.1. Raspberry Pi 4 Model B

Connect the _USB-C power port_ of your Pi 4B via cable with a USB port on your target device. You should hear the USB connection sound (depending on the target device) and be able to access your target device wirelessly using your Bluetooth keyboard or mouse. In case the Pi solely draws power from the host, it will take some time for the Pi to boot.

> [!IMPORTANT]
> It's essential to use the small power port instead of the bigger USB-A ports, since only the power port has the [OTG](https://en.wikipedia.org/wiki/USB_On-The-Go) feature required for [USB gadgets](https://www.kernel.org/doc/html/latest/driver-api/usb/gadget.html).

#### 5.1.2. Raspberry Pi Zero (2) W(H)

For the Pi Zero, the situation is quite the opposite: Do _not_ use the power port to connect to the target device, _use_ the other port instead (typically labeled "DATA" or "USB"). You may connect the power port to a stable power supply.

### 5.2. Command-line arguments

Currently you can provide the following CLI arguments:

```console
user@pi0w:~ $ bluetooth_2_usb -h
usage: bluetooth_2_usb.py [--device_ids DEVICE_IDS] [--auto_discover] [--grab_devices] [--list_devices] [--log_to_file] [--log_path LOG_PATH] [--debug] [--version] [--help]

Bluetooth to USB HID relay. Handles Bluetooth keyboard and mouse events from multiple input devices and translates them to USB using Linux's gadget mode.

options:
  --device_ids DEVICE_IDS, -i DEVICE_IDS
                        Comma-separated list of identifiers for input devices to be relayed.
                        An identifier is either the input device path, the MAC address or any case-insensitive substring of the device name.
                        Example: --device_ids '/dev/input/event2,a1:b2:c3:d4:e5:f6,0A-1B-2C-3D-4E-5F,logi'
                        Default: None
  --auto_discover, -a   Enable auto-discovery mode. All readable input devices will be relayed automatically.
                        Default: disabled
  --grab_devices, -g    Grab the input devices, i.e., suppress any events on your relay device.
                        Devices are not grabbed by default.
  --list_devices, -l    List all available input devices and exit.
  --log_to_file, -f     Add a handler that logs to file, additionally to stdout.
  --log_path LOG_PATH, -p LOG_PATH
                        The path of the log file
                        Default: /var/log/bluetooth_2_usb/bluetooth_2_usb.log
  --debug, -d           Enable debug mode (Increases log verbosity)
                        Default: disabled
  --version, -v         Display the version number of this software and exit.
  --help, -h            Show this help message and exit.
```

### 5.3. Consuming the API from your Python code

The API is designed such that it may be consumed both via CLI and from within external Python code. More details on this [coming soon](https://github.com/quaxalber/bluetooth_2_usb/issues/16)!

## 6. Updating

You may update to the latest stable release by running:

```console
sudo ~/bluetooth_2_usb/scripts/update.sh
```

> [!NOTE]
> The update script performs a clean reinstallation, that is run `uninstall.sh`, delete the repo folder, clone again and run the install script. The current branch will be maintained.

## 7. Uninstallation

You may uninstall Bluetooth 2 USB by running:

```console
sudo ~/bluetooth_2_usb/scripts/uninstall.sh
```

## 8. Troubleshooting

### 8.1. The Pi keeps rebooting or crashes randomly

This is likely due to the limited power the Pi can draw from the host's USB port. Try these steps:

- If available, connect your Pi to a USB 3 port on the host / target device (usually blue) or preferably USB-C.
 
> [!IMPORTANT]
> *Do not use* the blue (or black) USB-A ports *of your Pi* to connect. **This won't work.**
>
> *Do use* the small USB-C power port (in case of Pi 4B). For Pi Zero, use the data port to connect to the host and attach the power port to a dedicated power supply.

- Try to [connect to the Pi via SSH](#41-prerequisites) instead of attaching a display directly and remove any unnecessary peripherals.
 
- Install a [lite version](https://downloads.raspberrypi.org/raspios_lite_arm64/images/) of your OS on the Pi (without GUI)
 
- For Pi 4B: Get a [USB-C Data/Power Splitter](https://thepihut.com/products/usb-c-data-power-splitter) and draw power from a dedicated power supply. This should ultimately resolve any power-related issues, and your Pi 4B will no longer be dependent on the host's power supply.
 
> [!NOTE]
> The Pi Zero is recommended to have a 1.2 A power supply for stable operation, the Pi Zero 2 requires 2.0 A and the Pi 4B even 3.0 A, while hosts may typically only supply up to 0.5/0.9 A through USB-A 2.0/3.0 ports. However, this may be sufficient depending on your specific soft- and hardware configuration. For more information see the [Raspberry Pi documentation](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#power-supply).

### 8.2. The installation was successful, but I don't see any output on the target device

This could be due to a number of reasons. Try these steps:

- Verify that the service is running:
 
  ```console
  service bluetooth_2_usb status
  ```

- Verify that you specified the correct input devices in `bluetooth_2_usb.service`
 
- Verify that your Bluetooth devices are paired, trusted, connected and *not* blocked:
 
  ```console
  bluetoothctl
  info A1:B2:C3:D4:E5:F6
  ```
 
  It should look like this:

  ```console
  user@pi0w:~ $ bluetoothctl
  Agent registered
  [CHG] Controller 0A:1B:2C:3D:4E:5F Pairable: yes
  [AceRK]# info A1:B2:C3:D4:E5:F6
  Device A1:B2:C3:D4:E5:F6 (random)
          Name: AceRK
          Alias: AceRK
          Paired: yes     <---
          Trusted: yes    <---
          Blocked: no     <---
          Connected: yes  <---
          WakeAllowed: no
          LegacyPairing: no
          UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
          UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
          UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
          UUID: Human Interface Device    (00001812-0000-1000-8000-00805f9b34fb)
          UUID: Nordic UART Service       (6e400001-b5a3-f393-e0a9-e50e24dcca9e)
  ```
 
> [!NOTE]
> Replace `A1:B2:C3:D4:E5:F6` by your input device's Bluetooth MAC address

- Reload and restart service:
 
  ```console
  sudo systemctl daemon-reload && sudo service bluetooth_2_usb restart
  ```

- Reboot Pi
 
  ```console
  sudo reboot
  ```

- Re-connect the Pi to the host and check that the cable is capable of transmitting data, not power only
 
- Try a different USB port on the host
 
- Try connecting to a different host

### 8.3. In bluetoothctl, my device is constantly switching on/off

This is a common issue, especially when the device gets paired with multiple hosts. One simple fix/workaround is to re-pair the device:

```console
bluetoothctl
power off
power on
block A1:B2:C3:D4:E5:F6
remove A1:B2:C3:D4:E5:F6
scan on
trust A1:B2:C3:D4:E5:F6
pair A1:B2:C3:D4:E5:F6
connect A1:B2:C3:D4:E5:F6
```

If the issue persists, it's worth trying to delete the cache:

```console
sudo -i
cd '/var/lib/bluetooth/0A:1B:2C:3D:4E:5F/cache'
rm -rf 'A1:B2:C3:D4:E5:F6'
exit
```

> [!NOTE]
> Replace `0A:1B:2C:3D:4E:5F` by your Pi's Bluetooth controller's MAC and `A1:B2:C3:D4:E5:F6` by your input device's MAC

### 8.4. I have a different issue

Here's a few things you could try:

- Check the log files (default at `/var/log/bluetooth_2_usb/`) for errors
 
> [!NOTE]
> Logging to file requires the `-f` flag

- You may also query the journal to inspect the service logs in real-time:
 
  ```console
  journalctl -u bluetooth_2_usb.service -n 50 -f
  ```

- For easier degguging, you may temporarily stop the service and run the script manually, modifying arguments as required, e.g., increase log verbosity by appending `-d`:

  ```console
  sudo service bluetooth_2_usb stop && sudo bluetooth_2_usb -ad ; sudo service bluetooth_2_usb start
  ```

- When you interact with your Bluetooth devices with `-d` set, you should see debug output in the logs such as:

  ```console
  user@pi0w:~/bluetooth_2_usb $ sudo service bluetooth_2_usb stop && sudo bluetooth_2_usb -i hdmi,a1:b2:c3:d4:e5:f6,/dev/input/event3 -d ; sudo service bluetooth_2_usb start
  23-12-16 15:52:21 [DEBUG] CLI args: device_ids=['hdmi', 'a1:b2:c3:d4:e5:f6', '/dev/input/event3'], auto_discover=False, grab_devices=False, list_devices=False, log_to_file=False, log_path=/var/log/bluetooth_2_usb/bluetooth_2_usb.log, debug=True, version=False
  23-12-16 15:52:21 [DEBUG] Logging to stdout
  23-12-16 15:52:21 [INFO] Launching Bluetooth 2 USB v0.8.0
  23-12-16 15:52:21 [INFO] Discovering input devices...
  23-12-16 15:52:21 [DEBUG] Relaying devices with matching name "hdmi" or MAC "a1:b2:c3:d4:e5:f6" or path "/dev/input/event3"
  23-12-16 15:52:21 [DEBUG] Initializing USB gadgets...
  23-12-16 15:52:24 [DEBUG] Enabled USB gadgets: [mouse gadget (/dev/hidg0), keyboard gadget (/dev/hidg1), consumer control gadget (/dev/hidg2)]
  23-12-16 15:52:24 [INFO] Activated relay for device /dev/input/event2, name "AceRK Mouse", phys "0a:1b:2c:3d:4e:5f"
  23-12-16 15:52:24 [INFO] Activated relay for device /dev/input/event1, name "AceRK Keyboard", phys "0a:1b:2c:3d:4e:5f"
  23-12-16 15:52:24 [INFO] Activated relay for device /dev/input/event0, name "vc4-hdmi", phys "vc4-hdmi/input0"
  ### Manually switched Pi's Bluetooth off ###
  23-12-16 15:53:27 [CRITICAL] Connection to AceRK Keyboard lost [OSError(19, 'No such device')]
  23-12-16 15:53:27 [CRITICAL] Connection to AceRK Mouse lost [OSError(19, 'No such device')]
  ### Manually switched Pi's Bluetooth back on ###
  23-12-16 15:53:31 [INFO] Activated relay for device /dev/input/event2, name "AceRK Mouse", phys "0a:1b:2c:3d:4e:5f"
  23-12-16 15:53:31 [INFO] Activated relay for device /dev/input/event1, name "AceRK Keyboard", phys "0a:1b:2c:3d:4e:5f"
  23-12-16 15:54:20 [DEBUG] Received event at 1702738460.417525, code 04, type 04, val 458827 from AceRK Keyboard
  23-12-16 15:54:20 [DEBUG] Received key event at 1702738460.417525, 104 (KEY_PAGEUP), down from AceRK Keyboard
  23-12-16 15:54:20 [DEBUG] Converted evdev scancode 0x68 (KEY_PAGEUP) to HID UsageID 0x4B (PAGE_UP)
  23-12-16 15:54:20 [DEBUG] Pressing PAGE_UP (0x4B) on keyboard gadget (/dev/hidg1)
  23-12-16 15:54:20 [DEBUG] Received synchronization event at 1702738460.417525, SYN_REPORT from AceRK Keyboard
  23-12-16 15:54:20 [DEBUG] Received event at 1702738460.466388, code 04, type 04, val 458827 from AceRK Keyboard
  23-12-16 15:54:20 [DEBUG] Received key event at 1702738460.466388, 104 (KEY_PAGEUP), up from AceRK Keyboard
  23-12-16 15:54:20 [DEBUG] Converted evdev scancode 0x68 (KEY_PAGEUP) to HID UsageID 0x4B (PAGE_UP)
  23-12-16 15:54:20 [DEBUG] Releasing PAGE_UP (0x4B) on keyboard gadget (/dev/hidg1)
  23-12-16 15:54:20 [DEBUG] Received synchronization event at 1702738460.466388, SYN_REPORT from AceRK Keyboard
  23-12-16 15:54:34 [DEBUG] Received event at 1702738474.116380, code 04, type 04, val 786665 from AceRK Keyboard
  23-12-16 15:54:34 [DEBUG] Received key event at 1702738474.116380, 115 (KEY_VOLUMEUP), down from AceRK Keyboard
  23-12-16 15:54:34 [DEBUG] Converted evdev scancode 0x73 (KEY_VOLUMEUP) to HID UsageID 0xE9 (VOLUME_INCREMENT)
  23-12-16 15:54:34 [DEBUG] Pressing VOLUME_INCREMENT (0xE9) on consumer control gadget (/dev/hidg2)
  23-12-16 15:54:34 [DEBUG] Received synchronization event at 1702738474.116380, SYN_REPORT from AceRK Keyboard
  23-12-16 15:54:34 [DEBUG] Received event at 1702738474.117192, code 04, type 04, val 786665 from AceRK Keyboard
  23-12-16 15:54:34 [DEBUG] Received key event at 1702738474.117192, 115 (KEY_VOLUMEUP), up from AceRK Keyboard
  23-12-16 15:54:34 [DEBUG] Converted evdev scancode 0x73 (KEY_VOLUMEUP) to HID UsageID 0xE9 (VOLUME_INCREMENT)
  23-12-16 15:54:34 [DEBUG] Releasing VOLUME_INCREMENT (0xE9) on consumer control gadget (/dev/hidg2)
  23-12-16 15:54:34 [DEBUG] Received synchronization event at 1702738474.117192, SYN_REPORT from AceRK Keyboard
  23-12-16 15:54:36 [DEBUG] Received event at 1702738476.895033, code 04, type 04, val 589826 from AceRK Mouse
  23-12-16 15:54:36 [DEBUG] Received key event at 1702738476.895033, 273 (BTN_RIGHT), down from AceRK Mouse
  23-12-16 15:54:36 [DEBUG] Converted evdev scancode 0x111 (BTN_RIGHT) to HID UsageID 0x02 (RIGHT)
  23-12-16 15:54:36 [DEBUG] Pressing RIGHT (0x02) on mouse gadget (/dev/hidg0)
  23-12-16 15:54:36 [DEBUG] Received synchronization event at 1702738476.895033, SYN_REPORT from AceRK Mouse
  23-12-16 15:54:36 [DEBUG] Received event at 1702738476.943781, code 04, type 04, val 589826 from AceRK Mouse
  23-12-16 15:54:36 [DEBUG] Received key event at 1702738476.943781, 273 (BTN_RIGHT), up from AceRK Mouse
  23-12-16 15:54:36 [DEBUG] Converted evdev scancode 0x111 (BTN_RIGHT) to HID UsageID 0x02 (RIGHT)
  23-12-16 15:54:36 [DEBUG] Releasing RIGHT (0x02) on mouse gadget (/dev/hidg0)
  23-12-16 15:54:36 [DEBUG] Received synchronization event at 1702738476.943781, SYN_REPORT from AceRK Mouse
  23-12-16 15:54:37 [DEBUG] Received relative axis event at 1702738477.675038, REL_X from AceRK Mouse
  23-12-16 15:54:37 [DEBUG] Moving mouse gadget (/dev/hidg0) (x=125, y=0, mwheel=0)
  23-12-16 15:54:37 [DEBUG] Received synchronization event at 1702738477.675038, SYN_REPORT from AceRK Mouse
  ^C23-12-16 15:54:50 [INFO] Received signal: SIGINT, frame: <frame at 0xb5ec9930, file '/usr/lib/python3.11/selectors.py', line 468, code select>
  23-12-16 15:54:50 [CRITICAL] vc4-hdmi was cancelled
  23-12-16 15:54:50 [CRITICAL] AceRK Keyboard was cancelled
  23-12-16 15:54:50 [CRITICAL] AceRK Mouse was cancelled
  ```

- Still not resolved? Double-check the [installation instructions](#4-installation)
 
- For more help, open an [issue](https://github.com/quaxalber/bluetooth_2_usb/issues) in the [GitHub repository](https://github.com/quaxalber/bluetooth_2_usb)

### 8.5. Everything is working, but can it help me with Bitcoin mining?

Absolutely! [Here's how](https://bit.ly/42BTC).

## 9. Bonus points

After successfully setting up your Pi as a HID proxy for your Bluetooth devices, you may consider making [Raspberry Pi OS read-only](https://learn.adafruit.com/read-only-raspberry-pi/overview). That helps preventing the SD card from wearing out and the file system from getting corrupted when powering off the Raspberry forcefully.

## 10. Contributing

Contributions are welcome! Please read the [CONTRIBUTING.md](https://github.com/quaxalber/bluetooth_2_usb/blob/main/CONTRIBUTING.md) file for guidelines.

## 11. License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/quaxalber/bluetooth_2_usb/blob/main/LICENSE) file for details.

"Bluetooth 2 HID" image [@PixelGordo](https://twitter.com/PixelGordo) is licensed under a [Creative Commons Attribution-NonCommercial 4.0 International License](http://creativecommons.org/licenses/by-nc/4.0/).

![License image.](https://i.creativecommons.org/l/by-nc/4.0/88x31.png)

## 12. Acknowledgments

* [Mike Redrobe](https://github.com/mikerr/pihidproxy) for the idea and the basic code logic and [HeuristicPerson's bluetooth_2_hid](https://github.com/HeuristicPerson/bluetooth_2_hid) based off this.
* [Georgi Valkov](https://github.com/gvalkov) for [python-evdev](https://github.com/gvalkov/python-evdev) making reading input devices a walk in the park.
* The folks at [Adafruit](https://www.adafruit.com/) for [CircuitPython HID](https://github.com/adafruit/Adafruit_CircuitPython_HID) and [Blinka](https://github.com/quaxalber/Adafruit_Blinka/blob/main/src/usb_hid.py) providing super smooth access to USB gadgets.
* Special thanks to the open-source community for various other libraries and tools.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bluetooth-2-usb",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "adapter,proxy,relay,bluetooth,usb,hid,human,interface,device,keyboard,mouse,consumer,keycode,keypadhardware,raspberry,evdev",
    "author": "",
    "author_email": "quaxalber <pypi@quaxalber.de>",
    "download_url": "https://files.pythonhosted.org/packages/81/e8/985da3db5572a2bd6865bfc71f08c06b4627e7d8519dfb5043d06b2beb44/bluetooth_2_usb-0.8.0.tar.gz",
    "platform": null,
    "description": "<!-- omit in toc -->\n# Bluetooth to USB\n\n![Connection overview](assets/overview.png)\n\n<!-- omit in toc -->\n## Table of Contents\n\n- [1. Introduction](#1-introduction)\n- [2. Features](#2-features)\n- [3. Requirements](#3-requirements)\n- [4. Installation](#4-installation)\n  - [4.1. Prerequisites](#41-prerequisites)\n  - [4.2. Setup](#42-setup)\n- [5. Usage](#5-usage)\n  - [5.1. Connection to target device / host](#51-connection-to-target-device--host)\n    - [5.1.1. Raspberry Pi 4 Model B](#511-raspberry-pi-4-model-b)\n    - [5.1.2. Raspberry Pi Zero (2) W(H)](#512-raspberry-pi-zero-2-wh)\n  - [5.2. Command-line arguments](#52-command-line-arguments)\n  - [5.3. Consuming the API from your Python code](#53-consuming-the-api-from-your-python-code)\n- [6. Updating](#6-updating)\n- [7. Uninstallation](#7-uninstallation)\n- [8. Troubleshooting](#8-troubleshooting)\n  - [8.1. The Pi keeps rebooting or crashes randomly](#81-the-pi-keeps-rebooting-or-crashes-randomly)\n  - [8.2. The installation was successful, but I don't see any output on the target device](#82-the-installation-was-successful-but-i-dont-see-any-output-on-the-target-device)\n  - [8.3. In bluetoothctl, my device is constantly switching on/off](#83-in-bluetoothctl-my-device-is-constantly-switching-onoff)\n  - [8.4. I have a different issue](#84-i-have-a-different-issue)\n  - [8.5. Everything is working, but can it help me with Bitcoin mining?](#85-everything-is-working-but-can-it-help-me-with-bitcoin-mining)\n- [9. Bonus points](#9-bonus-points)\n- [10. Contributing](#10-contributing)\n- [11. License](#11-license)\n- [12. Acknowledgments](#12-acknowledgments)\n\n## 1. Introduction\n\nConvert a Raspberry Pi into a HID relay that translates Bluetooth keyboard and mouse input to USB. Minimal configuration. Zero hassle.\n\nThe issue with Bluetooth devices is that you usually can't use them to:\n- wake up sleeping devices,\n- access the BIOS or OS select menu (e.g., GRUB),\n- access devices without Bluetooth interface (e.g., devices in a restricted environment or most KVM switches).\n\nSounds familiar? Congratulations! **You just found the solution!**\n\nLinux's gadget mode allows a Raspberry Pi to act as USB HID (Human Interface Device). Therefore, from the host's perspective, it appears like a regular USB keyboard or mouse. You may think of your Pi as a multi-device Bluetooth dongle.\n\n## 2. Features\n\n- Simple installation and highly automated setup\n- Supports multiple input devices (currently keyboard and mouse - more than one of each kind simultaneously)\n- Supports [146 multimedia keys](https://github.com/quaxalber/bluetooth_2_usb/blob/8b1c5f8097bbdedfe4cef46e07686a1059ea2979/lib/evdev_adapter.py#L142) (e.g., mute, volume up/down, launch browser, etc.)\n- Auto-discovery feature for input devices\n- Auto-reconnect feature for input devices (power off, energy saving mode, out of range, etc.)\n- Robust error handling and logging\n- Installation as a systemd service\n- Reliable concurrency using state-of-the-art [TaskGroups](https://docs.python.org/3/library/asyncio-task.html#task-groups)\n- Clean and actively maintained code base\n\n## 3. Requirements\n\n- A Raspberry Pi with Bluetooth and [USB OTG support](https://en.wikipedia.org/wiki/USB_On-The-Go) required for [USB gadgets](https://www.kernel.org/doc/html/latest/driver-api/usb/gadget.html) in so-called device mode. Supported models include:\n  - **Raspberry Pi Zero W(H)**: Includes Bluetooth 4.1 and supports USB OTG with the lowest price tag.\n  - **Raspberry Pi Zero 2 W**: Similar to the Raspberry Pi Zero W, it has Bluetooth 4.1 and USB OTG support while providing additional processing power.\n  - **Raspberry Pi 4 Model B**: Offers Bluetooth 5.0 and USB-C OTG support for device mode, providing the best performance (that is until the Pi 5 is available).\n- Linux OS with systemd support (e.g., [Raspberry Pi OS](https://www.raspberrypi.com/software/), recommended).\n- Python 3.11 for using [TaskGroups](https://docs.python.org/3/library/asyncio-task.html#task-groups).\n\n> [!NOTE]\n> Raspberry Pi 3 Models feature Bluetooth 4.2 but no native USB gadget mode support. Earlier models like Raspberry Pi 1 and 2 do not support Bluetooth natively and have no USB gadget mode support.\n\n> [!NOTE]\n> The latest version of Raspberry Pi OS, based on Debian Bookworm, supports Python 3.11 through the official package repositories. For older versions, you may [build it from source](https://github.com/quaxalber/bluetooth_2_usb/blob/main/scripts/build_python_3.11.sh). Note that building may take anything between a few minutes (Pi 4B) and more than an hour (Pi 0W).\n\n## 4. Installation\n\nFollow these steps to install and configure the project:\n\n### 4.1. Prerequisites\n\n1. Install an OS on your Raspberry Pi (e.g., using [Pi Imager](https://youtu.be/ntaXWS8Lk34))\n  \n2. Connect to a network via Ethernet cable or [Wi-Fi](https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-networking). Make sure this network has Internet access.\n  \n3. (*optional, recommended*) Enable [SSH](https://www.raspberrypi.com/documentation/computers/remote-access.html#ssh), if you intend to access the Pi remotely.\n\n> [!NOTE]\n> These settings above may be configured [during imaging](https://www.raspberrypi.com/documentation/computers/getting-started.html#advanced-options) (recommended), [on first boot](https://www.raspberrypi.com/documentation/computers/getting-started.html#configuration-on-first-boot) or [afterwards](https://www.raspberrypi.com/documentation/computers/configuration.html).\n  \n4. Connect to the Pi and make sure `git` is installed:\n  \n   ```console\n   sudo apt update && sudo apt upgrade -y && sudo apt install -y git\n   ```\n\n5. Pair and trust any Bluetooth devices you wish to relay, either via GUI or via CLI:\n  \n   ```console\n   bluetoothctl\n   scan on\n   ```\n\n   ... wait for your devices to show up and note their MAC addresses (you may also type the first characters and hit `TAB` for auto-completion in the following commands) ...\n\n   ```console\n   trust A1:B2:C3:D4:E5:F6\n   pair A1:B2:C3:D4:E5:F6\n   connect A1:B2:C3:D4:E5:F6\n   ```\n\n> [!NOTE]\n> Replace `A1:B2:C3:D4:E5:F6` by your input device's Bluetooth MAC address\n\n### 4.2. Setup\n\n6. On the Pi, clone the repository to your home directory:\n  \n   ```console\n   cd ~ && git clone https://github.com/quaxalber/bluetooth_2_usb.git\n   ```\n\n7. Run the installation script as root:\n   \n   ```console\n   sudo ~/bluetooth_2_usb/scripts/install.sh\n   ```\n\n8.  Reboot:\n \n    ```console\n    sudo reboot\n    ``` \n\n9.  Verify that the service is running:\n   \n    ```console\n    service bluetooth_2_usb status\n    ```\n\n    It should look something like this and say `Active: active (running)`:\n\n    ```console\n    user@pi0w:~ $ service bluetooth_2_usb status\n    \u25cf bluetooth_2_usb.service - Bluetooth to USB HID relay\n        Loaded: loaded (/etc/systemd/system/bluetooth_2_usb.service; enabled; preset: enabled)\n        Active: active (running) since Wed 2023-12-13 10:33:00 CET; 44min ago\n      Main PID: 5865 (bash)\n          Tasks: 4 (limit: 389)\n            CPU: 2min 49.448s\n        CGroup: /system.slice/bluetooth_2_usb.service\n                \u251c\u25005865 bash /usr/bin/bluetooth_2_usb --auto_discover --grab_devices\n                \u2514\u25005869 python3.11 /home/user/bluetooth_2_usb/bluetooth_2_usb.py --auto_discover --grab_devices\n\n    Dec 13 10:33:00 pi0w systemd[1]: Started bluetooth_2_usb.service - Bluetooth to USB HID relay.\n    Dec 13 10:33:06 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:06 [INFO] Launching Bluetooth 2 USB v0.8.0\n    Dec 13 10:33:06 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:06 [INFO] Discovering input devices...\n    Dec 13 10:33:09 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:09 [INFO] Activated relay for device /dev/input/event2, name \"AceRK Mouse\", phys \"0a:1b:2c:3d:4e:5f\"\n    Dec 13 10:33:09 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:09 [INFO] Activated relay for device /dev/input/event1, name \"AceRK Keyboard\", phys \"0a:1b:2c:3d:4e:5f\"\n    Dec 13 10:33:09 pi0w bluetooth_2_usb[5869]: 23-12-13 10:33:09 [INFO] Activated relay for device /dev/input/event0, name \"vc4-hdmi\", phys \"vc4-hdmi/input0\"\n    ```\n\n> [!NOTE]\n> Something seems off? Try yourself in [Troubleshooting](#8-troubleshooting)!\n   \n## 5. Usage\n\n### 5.1. Connection to target device / host\n\n#### 5.1.1. Raspberry Pi 4 Model B\n\nConnect the _USB-C power port_ of your Pi 4B via cable with a USB port on your target device. You should hear the USB connection sound (depending on the target device) and be able to access your target device wirelessly using your Bluetooth keyboard or mouse. In case the Pi solely draws power from the host, it will take some time for the Pi to boot.\n\n> [!IMPORTANT]\n> It's essential to use the small power port instead of the bigger USB-A ports, since only the power port has the [OTG](https://en.wikipedia.org/wiki/USB_On-The-Go) feature required for [USB gadgets](https://www.kernel.org/doc/html/latest/driver-api/usb/gadget.html).\n\n#### 5.1.2. Raspberry Pi Zero (2) W(H)\n\nFor the Pi Zero, the situation is quite the opposite: Do _not_ use the power port to connect to the target device, _use_ the other port instead (typically labeled \"DATA\" or \"USB\"). You may connect the power port to a stable power supply.\n\n### 5.2. Command-line arguments\n\nCurrently you can provide the following CLI arguments:\n\n```console\nuser@pi0w:~ $ bluetooth_2_usb -h\nusage: bluetooth_2_usb.py [--device_ids DEVICE_IDS] [--auto_discover] [--grab_devices] [--list_devices] [--log_to_file] [--log_path LOG_PATH] [--debug] [--version] [--help]\n\nBluetooth to USB HID relay. Handles Bluetooth keyboard and mouse events from multiple input devices and translates them to USB using Linux's gadget mode.\n\noptions:\n  --device_ids DEVICE_IDS, -i DEVICE_IDS\n                        Comma-separated list of identifiers for input devices to be relayed.\n                        An identifier is either the input device path, the MAC address or any case-insensitive substring of the device name.\n                        Example: --device_ids '/dev/input/event2,a1:b2:c3:d4:e5:f6,0A-1B-2C-3D-4E-5F,logi'\n                        Default: None\n  --auto_discover, -a   Enable auto-discovery mode. All readable input devices will be relayed automatically.\n                        Default: disabled\n  --grab_devices, -g    Grab the input devices, i.e., suppress any events on your relay device.\n                        Devices are not grabbed by default.\n  --list_devices, -l    List all available input devices and exit.\n  --log_to_file, -f     Add a handler that logs to file, additionally to stdout.\n  --log_path LOG_PATH, -p LOG_PATH\n                        The path of the log file\n                        Default: /var/log/bluetooth_2_usb/bluetooth_2_usb.log\n  --debug, -d           Enable debug mode (Increases log verbosity)\n                        Default: disabled\n  --version, -v         Display the version number of this software and exit.\n  --help, -h            Show this help message and exit.\n```\n\n### 5.3. Consuming the API from your Python code\n\nThe API is designed such that it may be consumed both via CLI and from within external Python code. More details on this [coming soon](https://github.com/quaxalber/bluetooth_2_usb/issues/16)!\n\n## 6. Updating\n\nYou may update to the latest stable release by running:\n\n```console\nsudo ~/bluetooth_2_usb/scripts/update.sh\n```\n\n> [!NOTE]\n> The update script performs a clean reinstallation, that is run `uninstall.sh`, delete the repo folder, clone again and run the install script. The current branch will be maintained.\n\n## 7. Uninstallation\n\nYou may uninstall Bluetooth 2 USB by running:\n\n```console\nsudo ~/bluetooth_2_usb/scripts/uninstall.sh\n```\n\n## 8. Troubleshooting\n\n### 8.1. The Pi keeps rebooting or crashes randomly\n\nThis is likely due to the limited power the Pi can draw from the host's USB port. Try these steps:\n\n- If available, connect your Pi to a USB 3 port on the host / target device (usually blue) or preferably USB-C.\n \n> [!IMPORTANT]\n> *Do not use* the blue (or black) USB-A ports *of your Pi* to connect. **This won't work.**\n>\n> *Do use* the small USB-C power port (in case of Pi 4B). For Pi Zero, use the data port to connect to the host and attach the power port to a dedicated power supply.\n\n- Try to [connect to the Pi via SSH](#41-prerequisites) instead of attaching a display directly and remove any unnecessary peripherals.\n \n- Install a [lite version](https://downloads.raspberrypi.org/raspios_lite_arm64/images/) of your OS on the Pi (without GUI)\n \n- For Pi 4B: Get a [USB-C Data/Power Splitter](https://thepihut.com/products/usb-c-data-power-splitter) and draw power from a dedicated power supply. This should ultimately resolve any power-related issues, and your Pi 4B will no longer be dependent on the host's power supply.\n \n> [!NOTE]\n> The Pi Zero is recommended to have a 1.2 A power supply for stable operation, the Pi Zero 2 requires 2.0 A and the Pi 4B even 3.0 A, while hosts may typically only supply up to 0.5/0.9 A through USB-A 2.0/3.0 ports. However, this may be sufficient depending on your specific soft- and hardware configuration. For more information see the [Raspberry Pi documentation](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#power-supply).\n\n### 8.2. The installation was successful, but I don't see any output on the target device\n\nThis could be due to a number of reasons. Try these steps:\n\n- Verify that the service is running:\n \n  ```console\n  service bluetooth_2_usb status\n  ```\n\n- Verify that you specified the correct input devices in `bluetooth_2_usb.service`\n \n- Verify that your Bluetooth devices are paired, trusted, connected and *not* blocked:\n \n  ```console\n  bluetoothctl\n  info A1:B2:C3:D4:E5:F6\n  ```\n \n  It should look like this:\n\n  ```console\n  user@pi0w:~ $ bluetoothctl\n  Agent registered\n  [CHG] Controller 0A:1B:2C:3D:4E:5F Pairable: yes\n  [AceRK]# info A1:B2:C3:D4:E5:F6\n  Device A1:B2:C3:D4:E5:F6 (random)\n          Name: AceRK\n          Alias: AceRK\n          Paired: yes     <---\n          Trusted: yes    <---\n          Blocked: no     <---\n          Connected: yes  <---\n          WakeAllowed: no\n          LegacyPairing: no\n          UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)\n          UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)\n          UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)\n          UUID: Human Interface Device    (00001812-0000-1000-8000-00805f9b34fb)\n          UUID: Nordic UART Service       (6e400001-b5a3-f393-e0a9-e50e24dcca9e)\n  ```\n \n> [!NOTE]\n> Replace `A1:B2:C3:D4:E5:F6` by your input device's Bluetooth MAC address\n\n- Reload and restart service:\n \n  ```console\n  sudo systemctl daemon-reload && sudo service bluetooth_2_usb restart\n  ```\n\n- Reboot Pi\n \n  ```console\n  sudo reboot\n  ```\n\n- Re-connect the Pi to the host and check that the cable is capable of transmitting data, not power only\n \n- Try a different USB port on the host\n \n- Try connecting to a different host\n\n### 8.3. In bluetoothctl, my device is constantly switching on/off\n\nThis is a common issue, especially when the device gets paired with multiple hosts. One simple fix/workaround is to re-pair the device:\n\n```console\nbluetoothctl\npower off\npower on\nblock A1:B2:C3:D4:E5:F6\nremove A1:B2:C3:D4:E5:F6\nscan on\ntrust A1:B2:C3:D4:E5:F6\npair A1:B2:C3:D4:E5:F6\nconnect A1:B2:C3:D4:E5:F6\n```\n\nIf the issue persists, it's worth trying to delete the cache:\n\n```console\nsudo -i\ncd '/var/lib/bluetooth/0A:1B:2C:3D:4E:5F/cache'\nrm -rf 'A1:B2:C3:D4:E5:F6'\nexit\n```\n\n> [!NOTE]\n> Replace `0A:1B:2C:3D:4E:5F` by your Pi's Bluetooth controller's MAC and `A1:B2:C3:D4:E5:F6` by your input device's MAC\n\n### 8.4. I have a different issue\n\nHere's a few things you could try:\n\n- Check the log files (default at `/var/log/bluetooth_2_usb/`) for errors\n \n> [!NOTE]\n> Logging to file requires the `-f` flag\n\n- You may also query the journal to inspect the service logs in real-time:\n \n  ```console\n  journalctl -u bluetooth_2_usb.service -n 50 -f\n  ```\n\n- For easier degguging, you may temporarily stop the service and run the script manually, modifying arguments as required, e.g., increase log verbosity by appending `-d`:\n\n  ```console\n  sudo service bluetooth_2_usb stop && sudo bluetooth_2_usb -ad ; sudo service bluetooth_2_usb start\n  ```\n\n- When you interact with your Bluetooth devices with `-d` set, you should see debug output in the logs such as:\n\n  ```console\n  user@pi0w:~/bluetooth_2_usb $ sudo service bluetooth_2_usb stop && sudo bluetooth_2_usb -i hdmi,a1:b2:c3:d4:e5:f6,/dev/input/event3 -d ; sudo service bluetooth_2_usb start\n  23-12-16 15:52:21 [DEBUG] CLI args: device_ids=['hdmi', 'a1:b2:c3:d4:e5:f6', '/dev/input/event3'], auto_discover=False, grab_devices=False, list_devices=False, log_to_file=False, log_path=/var/log/bluetooth_2_usb/bluetooth_2_usb.log, debug=True, version=False\n  23-12-16 15:52:21 [DEBUG] Logging to stdout\n  23-12-16 15:52:21 [INFO] Launching Bluetooth 2 USB v0.8.0\n  23-12-16 15:52:21 [INFO] Discovering input devices...\n  23-12-16 15:52:21 [DEBUG] Relaying devices with matching name \"hdmi\" or MAC \"a1:b2:c3:d4:e5:f6\" or path \"/dev/input/event3\"\n  23-12-16 15:52:21 [DEBUG] Initializing USB gadgets...\n  23-12-16 15:52:24 [DEBUG] Enabled USB gadgets: [mouse gadget (/dev/hidg0), keyboard gadget (/dev/hidg1), consumer control gadget (/dev/hidg2)]\n  23-12-16 15:52:24 [INFO] Activated relay for device /dev/input/event2, name \"AceRK Mouse\", phys \"0a:1b:2c:3d:4e:5f\"\n  23-12-16 15:52:24 [INFO] Activated relay for device /dev/input/event1, name \"AceRK Keyboard\", phys \"0a:1b:2c:3d:4e:5f\"\n  23-12-16 15:52:24 [INFO] Activated relay for device /dev/input/event0, name \"vc4-hdmi\", phys \"vc4-hdmi/input0\"\n  ### Manually switched Pi's Bluetooth off ###\n  23-12-16 15:53:27 [CRITICAL] Connection to AceRK Keyboard lost [OSError(19, 'No such device')]\n  23-12-16 15:53:27 [CRITICAL] Connection to AceRK Mouse lost [OSError(19, 'No such device')]\n  ### Manually switched Pi's Bluetooth back on ###\n  23-12-16 15:53:31 [INFO] Activated relay for device /dev/input/event2, name \"AceRK Mouse\", phys \"0a:1b:2c:3d:4e:5f\"\n  23-12-16 15:53:31 [INFO] Activated relay for device /dev/input/event1, name \"AceRK Keyboard\", phys \"0a:1b:2c:3d:4e:5f\"\n  23-12-16 15:54:20 [DEBUG] Received event at 1702738460.417525, code 04, type 04, val 458827 from AceRK Keyboard\n  23-12-16 15:54:20 [DEBUG] Received key event at 1702738460.417525, 104 (KEY_PAGEUP), down from AceRK Keyboard\n  23-12-16 15:54:20 [DEBUG] Converted evdev scancode 0x68 (KEY_PAGEUP) to HID UsageID 0x4B (PAGE_UP)\n  23-12-16 15:54:20 [DEBUG] Pressing PAGE_UP (0x4B) on keyboard gadget (/dev/hidg1)\n  23-12-16 15:54:20 [DEBUG] Received synchronization event at 1702738460.417525, SYN_REPORT from AceRK Keyboard\n  23-12-16 15:54:20 [DEBUG] Received event at 1702738460.466388, code 04, type 04, val 458827 from AceRK Keyboard\n  23-12-16 15:54:20 [DEBUG] Received key event at 1702738460.466388, 104 (KEY_PAGEUP), up from AceRK Keyboard\n  23-12-16 15:54:20 [DEBUG] Converted evdev scancode 0x68 (KEY_PAGEUP) to HID UsageID 0x4B (PAGE_UP)\n  23-12-16 15:54:20 [DEBUG] Releasing PAGE_UP (0x4B) on keyboard gadget (/dev/hidg1)\n  23-12-16 15:54:20 [DEBUG] Received synchronization event at 1702738460.466388, SYN_REPORT from AceRK Keyboard\n  23-12-16 15:54:34 [DEBUG] Received event at 1702738474.116380, code 04, type 04, val 786665 from AceRK Keyboard\n  23-12-16 15:54:34 [DEBUG] Received key event at 1702738474.116380, 115 (KEY_VOLUMEUP), down from AceRK Keyboard\n  23-12-16 15:54:34 [DEBUG] Converted evdev scancode 0x73 (KEY_VOLUMEUP) to HID UsageID 0xE9 (VOLUME_INCREMENT)\n  23-12-16 15:54:34 [DEBUG] Pressing VOLUME_INCREMENT (0xE9) on consumer control gadget (/dev/hidg2)\n  23-12-16 15:54:34 [DEBUG] Received synchronization event at 1702738474.116380, SYN_REPORT from AceRK Keyboard\n  23-12-16 15:54:34 [DEBUG] Received event at 1702738474.117192, code 04, type 04, val 786665 from AceRK Keyboard\n  23-12-16 15:54:34 [DEBUG] Received key event at 1702738474.117192, 115 (KEY_VOLUMEUP), up from AceRK Keyboard\n  23-12-16 15:54:34 [DEBUG] Converted evdev scancode 0x73 (KEY_VOLUMEUP) to HID UsageID 0xE9 (VOLUME_INCREMENT)\n  23-12-16 15:54:34 [DEBUG] Releasing VOLUME_INCREMENT (0xE9) on consumer control gadget (/dev/hidg2)\n  23-12-16 15:54:34 [DEBUG] Received synchronization event at 1702738474.117192, SYN_REPORT from AceRK Keyboard\n  23-12-16 15:54:36 [DEBUG] Received event at 1702738476.895033, code 04, type 04, val 589826 from AceRK Mouse\n  23-12-16 15:54:36 [DEBUG] Received key event at 1702738476.895033, 273 (BTN_RIGHT), down from AceRK Mouse\n  23-12-16 15:54:36 [DEBUG] Converted evdev scancode 0x111 (BTN_RIGHT) to HID UsageID 0x02 (RIGHT)\n  23-12-16 15:54:36 [DEBUG] Pressing RIGHT (0x02) on mouse gadget (/dev/hidg0)\n  23-12-16 15:54:36 [DEBUG] Received synchronization event at 1702738476.895033, SYN_REPORT from AceRK Mouse\n  23-12-16 15:54:36 [DEBUG] Received event at 1702738476.943781, code 04, type 04, val 589826 from AceRK Mouse\n  23-12-16 15:54:36 [DEBUG] Received key event at 1702738476.943781, 273 (BTN_RIGHT), up from AceRK Mouse\n  23-12-16 15:54:36 [DEBUG] Converted evdev scancode 0x111 (BTN_RIGHT) to HID UsageID 0x02 (RIGHT)\n  23-12-16 15:54:36 [DEBUG] Releasing RIGHT (0x02) on mouse gadget (/dev/hidg0)\n  23-12-16 15:54:36 [DEBUG] Received synchronization event at 1702738476.943781, SYN_REPORT from AceRK Mouse\n  23-12-16 15:54:37 [DEBUG] Received relative axis event at 1702738477.675038, REL_X from AceRK Mouse\n  23-12-16 15:54:37 [DEBUG] Moving mouse gadget (/dev/hidg0) (x=125, y=0, mwheel=0)\n  23-12-16 15:54:37 [DEBUG] Received synchronization event at 1702738477.675038, SYN_REPORT from AceRK Mouse\n  ^C23-12-16 15:54:50 [INFO] Received signal: SIGINT, frame: <frame at 0xb5ec9930, file '/usr/lib/python3.11/selectors.py', line 468, code select>\n  23-12-16 15:54:50 [CRITICAL] vc4-hdmi was cancelled\n  23-12-16 15:54:50 [CRITICAL] AceRK Keyboard was cancelled\n  23-12-16 15:54:50 [CRITICAL] AceRK Mouse was cancelled\n  ```\n\n- Still not resolved? Double-check the [installation instructions](#4-installation)\n \n- For more help, open an [issue](https://github.com/quaxalber/bluetooth_2_usb/issues) in the [GitHub repository](https://github.com/quaxalber/bluetooth_2_usb)\n\n### 8.5. Everything is working, but can it help me with Bitcoin mining?\n\nAbsolutely! [Here's how](https://bit.ly/42BTC).\n\n## 9. Bonus points\n\nAfter successfully setting up your Pi as a HID proxy for your Bluetooth devices, you may consider making [Raspberry Pi OS read-only](https://learn.adafruit.com/read-only-raspberry-pi/overview). That helps preventing the SD card from wearing out and the file system from getting corrupted when powering off the Raspberry forcefully.\n\n## 10. Contributing\n\nContributions are welcome! Please read the [CONTRIBUTING.md](https://github.com/quaxalber/bluetooth_2_usb/blob/main/CONTRIBUTING.md) file for guidelines.\n\n## 11. License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/quaxalber/bluetooth_2_usb/blob/main/LICENSE) file for details.\n\n\"Bluetooth 2 HID\" image [@PixelGordo](https://twitter.com/PixelGordo) is licensed under a [Creative Commons Attribution-NonCommercial 4.0 International License](http://creativecommons.org/licenses/by-nc/4.0/).\n\n![License image.](https://i.creativecommons.org/l/by-nc/4.0/88x31.png)\n\n## 12. Acknowledgments\n\n* [Mike Redrobe](https://github.com/mikerr/pihidproxy) for the idea and the basic code logic and [HeuristicPerson's bluetooth_2_hid](https://github.com/HeuristicPerson/bluetooth_2_hid) based off this.\n* [Georgi Valkov](https://github.com/gvalkov) for [python-evdev](https://github.com/gvalkov/python-evdev) making reading input devices a walk in the park.\n* The folks at [Adafruit](https://www.adafruit.com/) for [CircuitPython HID](https://github.com/adafruit/Adafruit_CircuitPython_HID) and [Blinka](https://github.com/quaxalber/Adafruit_Blinka/blob/main/src/usb_hid.py) providing super smooth access to USB gadgets.\n* Special thanks to the open-source community for various other libraries and tools.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Convert a Raspberry Pi into a HID relay translating Bluetooth keyboard and mouse input to USB.",
    "version": "0.8.0",
    "project_urls": {
        "Homepage": "https://github.com/quaxalber/bluetooth_2_usb",
        "Issues": "https://github.com/quaxalber/bluetooth_2_usb/issues"
    },
    "split_keywords": [
        "adapter",
        "proxy",
        "relay",
        "bluetooth",
        "usb",
        "hid",
        "human",
        "interface",
        "device",
        "keyboard",
        "mouse",
        "consumer",
        "keycode",
        "keypadhardware",
        "raspberry",
        "evdev"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4cf4037c382b1d1299b28928eb50caaef03f2bba1e0148bad2abf5dab0f7efbd",
                "md5": "fb615fa22044d9e6bac338f639b27931",
                "sha256": "e1e4e7e0d4c3daabbf312c7d1147b4d27bc4702dc9ec2f735e6fc633681ed89c"
            },
            "downloads": -1,
            "filename": "bluetooth_2_usb-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb615fa22044d9e6bac338f639b27931",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 29252,
            "upload_time": "2023-12-17T12:15:42",
            "upload_time_iso_8601": "2023-12-17T12:15:42.104769Z",
            "url": "https://files.pythonhosted.org/packages/4c/f4/037c382b1d1299b28928eb50caaef03f2bba1e0148bad2abf5dab0f7efbd/bluetooth_2_usb-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "81e8985da3db5572a2bd6865bfc71f08c06b4627e7d8519dfb5043d06b2beb44",
                "md5": "666b4b8040db6643d71638c902311e35",
                "sha256": "94baa77b01d17a563fb5322b5803c81d4a199bbdfac6277e7139f4c56916d3d9"
            },
            "downloads": -1,
            "filename": "bluetooth_2_usb-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "666b4b8040db6643d71638c902311e35",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 221658,
            "upload_time": "2023-12-17T12:15:44",
            "upload_time_iso_8601": "2023-12-17T12:15:44.077775Z",
            "url": "https://files.pythonhosted.org/packages/81/e8/985da3db5572a2bd6865bfc71f08c06b4627e7d8519dfb5043d06b2beb44/bluetooth_2_usb-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-17 12:15:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "quaxalber",
    "github_project": "bluetooth_2_usb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "bluetooth-2-usb"
}
        
Elapsed time: 0.47426s