I will show you how to run these commands on boot gladly, but I must point out that you don't need to scan and pair the controller every time you boot the Edison. When you use Bluetooth and pair a device, that device is stored in a list of paired devices, so your Edison will be able to find your controller without the need of scan it first. In fact, in my experience, when I turn on the PS4 controller it automatically connects to my Edison because the Edison has it as a paired device as well as the PS4 controller has the Edison.
Being that said, I will show you how to create the service to connect the PS4 controller on boot (assuming that the PS4 controller has already been paired).
You will need to files, your script and your service. Both can be called however you like but the service must have the .service extension. For the sake of this example will call my files DS4_connect.sh and DS4_connect.service. The DS4_connect.sh file will be stored in /home/root/ (but you can change it to whatever you like) and the DS4_connect.service must be stored in /lib/systemd/system/.
DS4_connect.sh will look like the following:
#!/bin/sh rfkill unblock bluetooth sleep 1 bluetoothctl << EOF #agent on <---In my experience this lines are not needed #default-agent <---but if you have issues you can uncomment them. #power on <---Remember this script will only work if the #discoverable on <---controller has already been paired. connect 1C:96:5A:57:86:10 EOF sleep 1 #If you have to run any other script you can execute it here.
Make the script executable with the command:
chmod +x DS4_connect.sh
DS4_connect.service will look like the bellow:
#!/bin/sh [Unit] Description=Connects the DualShock4(TM) on boot [Service] ExecStart=/home/root/DS4_connect.sh Type=idle [Install] WantedBy=basic.target
Now you can enable the service and it should connect your Edison to your controller on boot (as long as the controller is available). To enable the service enter the command:
systemctl enable DS4_connect.service
Thank you so much! I really appreciate it