It works! (kind of)
After much work, we have a working rotary knob that can control the volume of the device it is connected to.
Rust embedded ecosystem is still pretty new, so I wasn’t able to find any library for making a HID device with Bluetooth LE. Instead, I had to manually write out the GATT services. Fortunately, it was easier than I thought, with only two being required for a working device. I also had to drop down to Windows (from my usual Linux) for a moment to generate a HID descriptor using the Waratah tool (https://github.com/microsoft/hidtools).
However, the biggest trouble, which took most of the time assigned to this devlog was getting the bluetooth device to connect and not get disconnected by OS or throw some error and disconnect itself. I spent probably another six hours not counted here, staring at logs, btmon, and searching about bluetooth pairing. So far, I haven’t managed to get a JustWorks pairing to work, and instead settled on a fake pin pairing. The device pretends it is displaying a pin to the user, and letting him confirm it, when actually it just automatically confirms it, and the user also does so on the device he intends to control. I believe the trouble with JustWorks authentication is caused by - guess it - trouble! - the BLE library I am using (pun intended). Another possibility is Linux causing problems or it might even be both.
I’m planning to open an issue on trouble github about this, and maybe the library can get fixed.
This project, while functional now, is also not yet done.
I still need to implement proper pairing data storage, so the device can reconnect after being powered off, I need to connect knob press to mute, and I need to make a physical package for the device, so it is actually usable. The authentication without pin is also something I would love to get working.
The video showcases the knob being used with a phone because it was easier to record, but it works with a pc too obviously.