2 Replies Latest reply on Feb 17, 2016 7:46 PM by dunex_1

    Connect PS4 Controller at boot up


      I know how to make a script to run at boot up but I do not know how to enable the following commands(bold words)  into a script so that I can be able to pair and connect my wireless controller


      root@edison:~# rfkill unblock bluetooth

      root@edison:~# bluetoothctl

      [NEW] Controller 98:4F:EE:03:62:87 edison [default]

      [bluetooth]# agent on

      Agent registered

      [bluetooth]# default-agent

      Default agent request successful

      [bluetooth]# power on

      Changing power on succeeded

      [bluetooth]# discoverable on

      Changing discoverable on succeeded

      [CHG] Controller 98:4F:EE:03:62:87 Discoverable: yes

      [bluetooth]# pairable on

      Changing pairable on succeeded

      [bluetooth]# scan on

      Discovery started

      [CHG] Controller 98:4F:EE:03:62:87 Discovering: yes

      [NEW] Device 1C:96:5A:57:86:10 Wireless Controller

      [NEW] Device 60:03:08:D3:60:A4 60-03-08-D3-60-A4

      [CHG] Device 1C:96:5A:57:86:10 RSSI: -63

      [bluetooth]# pair 1C:96:5A:57:86:10

      Attempting to pair with 1C:96:5A:57:86:10

      [CHG] Device 1C:96:5A:57:86:10 Connected: yes

      [CHG] Device 1C:96:5A:57:86:10 UUIDs:



      [CHG] Device 1C:96:5A:57:86:10 Paired: yes

      Pairing successful

      Authorize service 00001124-0000-1000-8000-00805f9b34fb (yes/no): yes

      [bluetooth]# [  383.526655] hid-generic 0005:054C:05C4.0001: unknown main item tag 0x0

      trust 1C:96:5A:57:86:10

      [CHG] Device 1C:96:5A:57:86:10 Trusted: yes

      Changing 1C:96:5A:57:86:10 trust succeeded

      [bluetooth]# connect 1C:96:5A:57:86:10

      Attempting to connect to 1C:96:5A:57:86:10

      Connection successful




      I saw some posts on how to enable Bluetooth but I did not see any post on how to implement the BLUETOOTHCTL command and CONNECT <device id> command on the script.


      Thank you in Advance!

        • 1. Re: Connect PS4 Controller at boot up

          Hello duex_1,


          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:


          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
          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:


          Description=Connects the DualShock4(TM) on boot


          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



          • 2. Re: Connect PS4 Controller at boot up



            Thank you so much! I really appreciate it