I have a mini Bluetooth keyboard and a Raspberry Pi running a Debian-based distro. I know the MAC address of the keyboard but for this question, let’s just use
AA:BB:CC:DD:EE:FF. Right now I have to have a wired keyboard connected as well as my Bluetooth dongle for the mini-keyboard. On the wired keyboard, I have to run the following when the device boots up:
sudo hidd --connect AA:BB:CC:DD:EE:FF
If the device goes idle for too long, then the Bluetooth disconnects and I have to pull out my wired keyboard and retype that same command.
What I’m looking for is a way to have that command run at startup and a way to sense if it gets disconnected so that it will auto reconnect.
The annoying thing is that the keyboard has to be in pairing mode (even though it has already been paired) when I run that command, otherwise it tells me the host is down. So perhaps the script needs to prevent it from disconnecting due to inactivity, otherwise I’ll have to put it back in pairing mode to reconnect.
So to recap:
- A script to connect at startup. I can make sure to put the keyboard into pairing mode before turning it on.
- A script to prevent it from disconnecting. Maybe some sort of signal to send to it every 60 seconds or something?