The steps for making an SPP connection manually without using SPP-loopbak.py are the following:
For this test a Nexus 5 with the free app Bluetooth SPP Manager was used***
Setting Edison to run SPP server
Search for the following line:
Change it for:
Setting the SPP connection
rfkill unblock bluetooth bluetoothctl agent DisplayYesNo default-agent scan on # #Discover your phone and find its MAC address # scan off pair XX:XX:XX:XX:XX:XX # #XX:XX:XX:XX:XX:XX represents your phone's MAC address, when entering the commands remember to change it #Say yes to everything on your Edison and hit the pair button on your phone # trust XX:XX:XX:XX:XX:XX quit sdptool add --channel=22 SP rfcomm watch /dev/rfcomm0 22 > /dev/null & bluetoothctl discoverable on quit # #Connect for your phone to the Edison establishing the SPP connection # cat /dev/rfcomm0
If you follow these steps you should be able to catch the SPP data. Now, you can apply this procedure to your project by calling these commands from your code with system calls. In your case I'd suggest you to create a system service that does the Bluetooth configuring for you so you don't have to include it on your code, in that case I'd suggest you to read Automatically connect to a device through Bluetooth.
Let me know if this helps.
Okay, so I'm able to connect, and send data from my phone (I'm using a Nexus 5 too) to the Edison, and the data will appear in the terminal. But how to I access it in my Java code? I'll need an instance of the connection somehow, right? I originally thought I'd be able to use the UART0 port, but I haven't been able to open that the same way I did the UART1 and UART2 ports.
I believe the best option would be to store the data in files, and then opening those files in Java to be used within the code. This shouldn't be that hard, but you might have to create a method that catches the data you are interested in within a file, then closes the process, opens the file in Java and then store the data in a variable.