How to run SPP-loopback.py on Edison

Version 5

    Update of 4/12/17:

     

    The images 3.0 and up have issues with the SPP profile when using the standard BlueZ package that comes pre-installed on them. In order to fix this issue please enter these commands:

     

    opkg remoce bluez5 --force-removal-of-dependent-packages

    wget https://iotdk.intel.com/repos/2.0/iotdk/core2-32/bluez5_5.22-r0.0_core2-32.ipk --no-check-certificate

    opkg install bluez5_5.22-r0.0_core2-32.ipk

     

    The instructions below should work after changing the BlueZ package to version 5.22.

     

    Update of 5/3/17:

     

    Step 1 is no longer needed if you are on the image 3.5. If you are indeed using this image, you can simply skip this step and start on step 2.

     

    ==============================================================================================================================================

    Original document as follows:

     

    This document will try to exemplify how to establish an SPP connection to an Android device. All steps were tested on the latest official image for Edison (release 2.1 when published).

     

    1. Modify the file "bluetooth.conf" found under /etc/dbus-1/system.d/:

         Add the line: <allow send_interface="org.bluez.Profile1"/>

              -Under the section: <policy context="default">

                   -Between the lines:

                        -<allow send_interface="org.bluez.MediaEndpoint1"/>

                    -And:

                        -<allow send_interface="org.bluez.ThermometerWatcher1"/>

    1.PNG

    2. Reboot the board and make sure the Bluetooth service starts correctly. If it fails to start, the file probably was not edited correctly. In that case reflash the board and try again.

     

    3. Enter the command: rfkill unblock bluetooth.

     

    4. Enter the command: bluetoothctl.

     

    5. Enter the command: agent DisplayYesNo.

     

    6. Enter the command: default-agent.

     

    7. Enter the command: scan on.

     

    8. Wait until you find your phone's MAC address and copy it. Make sure to make your phone visible from its settings.

     

    9. Enter the command: scan off.

     

    10. Enter the command: pair XX:XX:XX:XX:XX:XX. Where XX:XX:XX:XX:XX:XX represents your phone's MAC address.

     

    11. The following message will appear:

        -Attempting to pair with XX:XX:XX:XX:XX:XX

        -[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes

        -Request confirmation

        -[agent] Confirm passkey 000000 (yes/no):

        -Type yes and hit enter.

     

    12. Enter the command: connect XX:XX:XX:XX:XX:XX. Where XX:XX:XX:XX:XX:XX represents your phone's MAC address.

     

    13. On the bottom of this document you can find attached the SPP-loopback.py source code. Copy it and paste it to a file with the same name on your Edison.

     

    14. Enter the command: trust XX:XX:XX:XX:XX:XX. Where XX:XX:XX:XX:XX:XX represents your phone's MAC address.

     

    15. Enter the command: discoverable on.

     

    16. Enter the command: quit.

     

    17. Go to the directory where you stored the SPP-loopback.py file and enter the command: python SPP-loopback.py -C 22. You can change the 22 value; it represents the port you will be using to establish the serial connection.

     

    18. On your phone, you can use the free app Bluetooth SPP Tools Pro. Open it and search for your Edison. Once it’s found hit the connect button. Now the SPP connection should be established and you should be able to see the loopback on your Edison.

    2.PNG