Most active commenters

    ←back to thread

    233 points bahaaador | 13 comments | | HN request time: 1.011s | source | bottom

    Hi HN! I built Bluetooth USB Peripheral Relay, a tool that lets Bluetooth devices (like keyboards and mice) connect to USB-only hosts using a Raspberry Pi Zero W.

    Why? My friend needed a way to use his Bluetooth mouse and keyboard on a PC with Bluetooth disabled due to policy restrictions. This tool acts as a bridge, relaying Bluetooth input over USB. It also lets you use Bluetooth peripherals with older devices that only support USB input.

    Tech: Written in Go, optimized for Raspberry Pi Zero W.

    I love HN’s community and often lurk here—I’m hoping this project is useful or at least sparks some interesting discussions. Feedback and contributions are welcome!

    1. reeddavid ◴[] No.42128036[source]
    This solves a huge annoyance I've had: swap a Bluetooth keyboard/mouse between multiple laptops, without manually un0paring / re-pairing. I have a personal "hot desk" at home. I want to be able to plug in any laptop to the large monitor, and have the wireless keyboard/mouse on that desk instantly work. And when I leave the desk with my laptop, I don't want that keyboard/mouse connected anymore.

    This has been impossible so far, because even USB bluetooth dongles still require each host computer to pair (and un-pair) with the keyboard/mouse.

    I am going to try your solution, and I will plug the USB input into the large monitor on my desk. Then any laptop that plugs into that monitor should have access to the wireless keyboard/mouse. Thank you for creating and sharing this!

    replies(6): >>42128135 #>>42128230 #>>42128587 #>>42128744 #>>42129328 #>>42130139 #
    2. mmh0000 ◴[] No.42128135[source]
    All of this is being insanely overcomplicated.

    Throwing more complexity at a simple problem might be "fun" from a nerd's POV, and, TBH, building this USB device sounds fun. But entirely unneeded while introducing more points of failure.

    A simple solution to your problem:

    1. Get a monitor with a built-in USB hub (nearly all of them?). Consider getting a USB-C monitor to reduce the number of cables to 1.

    2. Don't use Bluetooth (for a keyboard, for multiple reasons, like needing the keyboard available in early boot). Get a keyboard/mouse with an external USB dongle like Logitech's Unify or Bolt, Corsair's SLIPSTREAM, or any of the other billion options that exist.

    3. Plug keyboard/mouse into monitor, plug random computers into monitor. Bam. Unified mouse and keyboard without any pairing.

    replies(2): >>42128204 #>>42128710 #
    3. FredFS456 ◴[] No.42128204[source]
    A cheap USB switch would also work, that would reduce the switching to switching monitor inputs and pressing the button the USB switch
    replies(2): >>42129744 #>>42129964 #
    4. bahaaador ◴[] No.42128230[source]
    My pleasure, @reeddavid! I’m excited that you might find a use for it. Just a quick note: you may need an external power source for the RPi if you’re switching between devices frequently.

    One popular request I’ve received is for certain RPi models (those with multiple USB ports as host) to act as a KVM, allowing them to serve as a USB host for multiple PCs simultaneously with easy switching—perhaps through shortcuts or physical buttons on the RPi. I’ll need to give it more thought, but it seems feasible with minimal changes. I already have some ideas for better state management for the devices!

    5. vel0city ◴[] No.42128587[source]
    I've had many BT mouse and keyboards which supported multiple pairing profiles on the device. When I want to switch the device I just press a button on the mouse or keyboard and it's connected almost instantly.

    My current keyboard:

    https://www.logitech.com/en-us/products/keyboards/mx-mechani...

    6. derefr ◴[] No.42128710[source]
    So your solution to solving one tiny flaw with the GP's otherwise-working setup is to... throw away their monitor, keyboard, and mouse, and spend lots of money (many times more money than an RPi-with-a-hat costs) to replace them?

    All because you're offended by the complexity of... what?

    • The idea of a device that acts as a stable host for Bluetooth devices, while presenting as a wired USB hub to an upstream USB host controller?

    • The particular implementation here, which is a hacky proof-of-concept of the idea (and which could, in practice, be reduced to a single chip embedded into any USB-C-dock product if there was demand)?

    • The entire concept of Bluetooth?

    ---

    Also, I would like to point out that, given that this is HN, it's more than even odds that the GP:

    • likely has multiple monitors (so using a monitor with a built-in hub is likely untenable);

    • and also, that their laptops are probably Macbooks, and their mouse and keyboard are therefore very likely a Magic Keyboard and Magic Trackpad [for which there is no 1:1 substitute that does non-Bluetooth wireless while still having the same level of macOS support/integration];

    • and that, given what they've said, they're likely already using a Thunderbolt hub to talk to those multiple monitors + all their USB devices through "one cable" (and all they really want is to add one more USB connection to this dock to make it act like a "Bluetooth dock" too);

    • and that they likely have a big deep sit-stand desk, that they'd be cluttering/making it hard to put things on the 90% of the free "middle space" on, if they had to run actual wires from the keyboard and mouse over to the dock.

    7. clort ◴[] No.42128744[source]
    many Bluetooth USB dongles have NVRAM, you can write the link key for a device (eg the keyboard or mouse) into the NVRAM and then when connecting, the dongle doesn't ask the Host computer for the key. I have used this to dual boot with a Bluetooth keyboard and mouse in the past.

    I think the technique would be: pair in machine A (A has a link key). Then, pair again in machine B with the same dongle. Write that key into NVRAM, and machine A considers the device paired but it never gets asked for the key so just works if you plug the dongle into either machine. I don't know how the monitor thing works, does it act as a USB hub? I guess you can just leave the Bluetooth dongle plugged in there..

    replies(1): >>42136498 #
    8. jauntywundrkind ◴[] No.42129328[source]
    Fun & cursed fact, the ArchWiki has a rather long section on dual boot pairing. Pair in Windows or Mac then painstakingly extract various bits of pairing info from the OS and toss it into Linux, so you can dual-boot & keep the pairing. https://wiki.archlinux.org/title/Bluetooth#Dual_boot_pairing

    I've always wondered how feasible it would be to copy Bluetooth pairing information. This particular series of hacks seems to rest at least somewhat on it being the same Bluetooth host adapter. (But maybe the host side can spoof, trade IDs with the other device?)

    Ideally I'd love to centrally and dynically manage what devices of mine are paired with what system... I think that might be technically feasible, as long as I'm not trying to pair multiple things with a single bt adapter.

    9. seiferteric ◴[] No.42129744{3}[source]
    I did this for a while but was a bit annoyed with the delay since it "unplugs" and "plugs" in the mouse/keyboard each time you hit the button. What I ended up doing is buying a used KVM switch with DDM (https://en.wikipedia.org/wiki/Dynamic_device_mapping) which allows pretty much instant switching.
    10. jwells89 ◴[] No.42129964{3}[source]
    Be careful with these though, a lot of USB switches (most readily available ones, even) aren't wired correctly and can result in current flowing from one computer to the other.
    11. lathiat ◴[] No.42130139[source]
    I had a similar problem but dual booting windows/linux. Though I managed to share the link keys with some registry hacks in the end.

    https://gist.github.com/madkoding/f3cfd3742546d5c99131fd19ca...

    12. redleader55 ◴[] No.42136498[source]
    This sounds extremely interesting. Do you have a link for such a USB dongle and how to write the key in the NVRAM?
    replies(1): >>42162829 #
    13. clort ◴[] No.42162829{3}[source]
    I have never a seen a Bluetooth adaptor without the capability. Currently this laptop has an "Intel Dual Band Wireless-AC 8265" device which reports it can store 16 keys in the NVRAM. I have used the btkey(1) program on NetBSD to read and write keys, but it is basically speaking directly directly to the adaptor so should be possible under any OS where that is possible.

    https://man.netbsd.org/btkey.1

    https://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/btkey/