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?)
Any help with this is greatly appreciated! StackOverflow is always the best place to find answers to weird questions! I've been searching long and hard for an answer, but finally had to resort to coming here!