Auto-connect Xiaomi Bluetooth Controller at start-up

It is one of the lesser known products from the Xiaomi stable but I am glad that it works fine on my RPi 2 using the Wireless Dualshock tutorial. If it is of any help to users of the same controller, the default discovery mode of long pressing the Mi button till it started flashing didn’t work out. I kind of went a bit mad after that and tried out different button combinations but as far as I can make out, pressing the Mi button when it is flashing along with one of the buttons (A, B, X, Y) did the trick. I had to then configure the controls manually but it is now working as fine as my XBox 360 controller.

The only gripe I have is auto-connecting the controller at start-up. The bluetooth service is starting up fine using the method mentioned in the tutorial, but I have to manually connect the controller each time using its MAC address from SSH. Once connected, the previously saved mapping works fine. So, is there a way to solve this minor irritant by getting Lakka to connect to the controller automatically at startup?

To add to my previous post, it is not only a start-up thing. If left idle for some time, the controller goes to sleep and loses the connection. When switched back on, it fails to connect automatically and has to be manually connected once again.

I don’t know much how the pairing process works. Any idea if the pairing information have to be saved both side?

All I can say for now, is that with the dualshock, this bug doesn’t happen.