hrvach / deskhop

Fast Desktop Switching Device
GNU General Public License v3.0
6.19k stars 177 forks source link

There is a better idea, Implementing HID KM with ESP32C3 BLE. #164

Open qq8322302 opened 1 week ago

qq8322302 commented 1 week ago

Hello,hrvach: I am an electronics enthusiast from China and came across your project by chance. It is a fantastic project that can solve many operational problems with multiple hosts. I have an idea now, to use ESP32C3 BLE to simulate keyboard, mouse, and communication with multiple devices, and to add lithium batteries to get rid of wiring harnesses.

My thoughts: ESP32C3 serves as the main controller, and after turning on BLE, it broadcasts four names: KM1, KM2, KM3, and KM4. Four PCs are connected to each of these four BLE names. The IO of ESP32C3 can use software to simulate USB-HOST mode for connecting keyboards and mice. (ESP32C3's ble_hid_device_demo: esp-idf-v5.2.1/examples/bluetooth/bluedroid/ble/ble_hid_device_demo) (ESP32C3 software simulation USB-HOST: https://github.com/sdima1357/esp32_usb_soft_host ) ESP32C3-FH4, In China, it only costs RMB 5 yuan, and materials such as batteries and casings are also very cheap. I can design and produce PCB hardware, but my software level is not very good. I wonder if you are interested in researching together?We look forward to your reply.

Snipaste_2024-10-18_11-19-13

chri2 commented 1 week ago

Sounds nice - I couldn't use it.

It will be a different device for end users without security needs.

My use case includes that I'm forbidden by rules at my work to use any keyboard that is connected wireless.

Making your project secure includes having a secure bluetooth stack which until now proved many times to be a wrong assumption.

Another point for me would be the needless use of batteries. That is not sustainable. There is no reason I can see that your idea couldn't work with one computer being connected through usb providing the power needed to drive your board (or just use an external usb power adaptor which in on most desks anyway.

I'd build or buy one for testing if it would work without a battery just for the fun of it and maybe to give it to my son to switch between his mobile and his desktop. On my desktop I couldn't use it for security reasons.

qq8322302 commented 6 days ago

@chri2 If for absolute safety, then wireless and lithium batteries are indeed not a good idea. Both will have certain security risks. If it's for convenience and a clean desktop, then wireless and lithium batteries will definitely be more convenient. This involves different usage scenarios.

tegger2000 commented 4 days ago

Maybe this project could be a base for your idea: https://github.com/Noskcaj19/hardware-kvm

hrvach commented 4 days ago

This is a cool idea - I've investigated ESP32 initially but it didn't have usb. My plan is to expand the nunmber of devices one can control, my initial thoughts were most people who would use this need 2, a small number might need 3 and very few people need 4 or more. I agree this would be a desirable feature for sure, I occasionally needed a third output, maybe something happens later this year :)

Some of the technical limitations mentioned were actually chosen on purpose, like omitting Bluetooth - I simply don't believe there is a vendor who could implement this in a way that stands the test of time (https://github.com/engn33r/awesome-bluetooth-security for reference). Bluetooth stacks are often written by coders faced with unrealistic timelines and then never ever patched after vulnerabilities are discovered. The protocol itself is a bit too complicated for a secure implementation.

If you're still interested in helping out, I'd be curious how cheap this board could be made, i.e. what the ultimate price point is for small(er) batches. I'll be working on a new PCB variant when time permits...

qq8322302 commented 1 day ago

Firstly, I would like to share a simplified version of the deskhop project that was created using the Raspberry Pi PICO development board and RP2040 * 2. The PCB was redesigned and streamlined to match the metal casing. Flashing the firmware of the desktop hop project has a very good effect.

IMG_20241025_210223 IMG_20241025_210300 IMG_20241025_212334 IMG_20241025_212535 IMG_20241025_212628


I found a similar project for ESP32C3 BLE: USB-HID-BLER, URL: https://github.com/dnstzzx/usb-hid-bler This project is to convert wired keyboard and mouse to BLE. I built a simple circuit and tested it. The mouse can be used normally, but the keyboard cannot be used. 
I have already drawn the PCB according to my idea, and it will take about a week to produce it. I will test it first when the time comes. There are the following software issues that need to be addressed:

  1. I don't know how ESP32C3 can emit KM1, KM2, KM3, KM4, multiple BLE names.
  2. The compatibility of USB-HID-BLER is not perfect and needs to be addressed.
  3. Need to merge the functions of deskhop into it.

Regarding small batch costs: PCB+materials+shell+production, about RMB 55 yuan. ( 8$ or 8€ )

I don't know if you're interested in helping write software? I can provide you with hardware.

Snipaste_2024-10-26_13-34-31

qq8322302 commented 1 day ago

Additionally, for users who prioritize safety and do not want to use BLE, we can use wired USB. I also have a better idea that can be extended to hardware solutions with 4 or even 8 hosts. It can be expanded using RP2040 1+analog switch+CH9329 N, and the price is also not expensive. RP2040 is connected to a keyboard and mouse, and at the same time, it is connected to 4 analog switches through UART * 1. By selecting which CH9329 to communicate with through GPIO, it can easily communicate with 1 out of N PCs. The disadvantage is that it can only communicate with one CH9329 at a time and cannot communicate simultaneously. If interested, I can also create this form of hardware, but I also need your software support.

image