It seems that you have done a good research about this. I haven't tested something similar to what you are trying to do, however, I found another guide that you might find useful. I'm not sure if you have checked it already, but I share the guide anyways: https://software.intel.com/en-us/blogs/2015/05/19/communicate-to-arduino-code-with-your-android-phone-by-bluetooth-serial-port
I'll keep looking for additional information about this. In the meantime, please let us know if you have ran additional tests about this so we can try to help you.
That is a good guide I have missed. I have read it through but I cannot do the last step: the BLE_SPP_PRO app cannot find my device. I have successfully paired my phone to my Edison module, scan on and discoverable is on, but the app cannot find my module.
Even if this worked then I am not sure how my Edison module can speak back to my phone. Through the app I can, following the guide, send some data to it. But I need to be able to do the other way around.
Do you know how I can achieve this?
Whenever I try the bluetooth service I get an error:
root@jayway-edison:~# systemctl status -l bluetooth-spp-pin
● bluetooth-spp-pin.service - Bluetooth SPP and PIN service
Loaded: loaded (/lib/systemd/system/bluetooth-spp-pin.service; enabled)
Active: active (exited) since Fri 2016-08-05 11:08:37 UTC; 19s ago
Process: 285 ExecStart=/home/root/bluetooth/bluetooth-spp-pin.sh (code=exited, status=0/SUCCESS)
Main PID: 285 (code=exited, status=0/SUCCESS)
Aug 05 11:08:38 jayway-edison systemd: Started Bluetooth SPP and PIN service.
Aug 05 11:08:41 jayway-edison bluetooth-spp-pin.sh: Can't get device info: No such device
Not sure if this is supposed to be, if the script should not be able to find the device. I cannot however still find my Edison module through the app.
Have you already checked the Bluetooth guide http://download.intel.com/support/edison/sb/edisonbluetooth_331704007.pdf ? It contains useful information that might help you configure Bluetooth.
Let us know your results.
Yes, I have looked at it.
The section 6.7.1 SPP verification using DBUS APIs only shows how to receive data:
"And on the Intel® Edison side, you can see the data received and retransmitted back:
root@edison:~# python ./SPP-loopback.py –C 22
received: cmd line mode testing SPP test
received: byte mode testing SPP profile in Edison"
How do I send data BACK to the Android device?
Hi,Let us know your results.
You can try to send/receive files with Obex. Obex is explained in section 6.13. You can see the guide here http://www.intel.com/content/www/us/en/support/boards-and-kits/000005743.html .
There’s some interesting information about obex and transferring data with Bluetooth in these threads:
So the OBEX profile really is an FTP operation? Then I would need an FTP client in my Android app or build on myself? And I do not want to send files between them, just some strings. For instance if I have an id then I want to send only this, not put that in a file and send that file.
Is there any way of sending data back to the app from the module? Sending data from the app to the module seems to work throughout the mentioned tutorials, but I only want to do the same but with the module to the app. I want the module to trigger the app, so it really is just one way the data has to go, from the module to the app. Later it will also be app to module but for now only module to app.
If you want just to send strings, try the SPP profile. I have a simple python code that a share some strings with a Android app.
On the Edison you should configure some things:
- Install Bluez, by download the source (wget this link) and make install inside the folder. (you will need setuptools installed first)
- Enable the compatibility mode for rfcomm see my post
- Enable the bluetooth:
rfkill unblock bluetooth
if it is the fist time, paring the Edison with your device using:
Then, Use this python code:
from bluetooth import *
server = BluetoothSocket(RFCOMM)
port = server.getsockname()
print 'port: ',port
uuid = "1101"
advertise_service( server, "SPP Service",
service_classes = [uuid, SERIAL_PORT_CLASS],
profiles = [SERIAL_PORT_PROFILE])
data = 's'
while data != 'q':
cli, addr = server.accept()
print "accepted", addr
data = 's'
while data != 'q' and data != 'e':
data = cli.recv(1024)
except btcommon.BluetoothError as error:
print 'Recv: ',error
data = 'e'
print "data: ",data
if data == 't':
print 'send test string'
Thank you for your reply. I cannot get this to work however. I followed what you wrote but I get this error:
root@edison:/home/bluetooth# python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from bluetooth import *
ImportError: No module named bluetooth
Do you know why I cannot find the bluetooth module? I wget the bluez and installed it, there were no problems there. Maybe this module is somewhere else?
Searching for this issue, this came up: it said the problem was that python-bluez was not installed. Do I also need this dependency? I thought that was what the link was that you gave me. I found some github repos with this, but I am not sure which one to try.
2 of 2 people found this helpful
I forgot to say about install PyBluez!
You could do this using pip...
Fist get you board online..
Then I suggest checking the date, and adjust to the current date:
date --set="22 aug 2016 09:48:00"
Then, install pip
opkg update pip install --upgrade pip
Then, install PyBluez
pip install --upgrade pybluez
This should solve the "ImportError: No module named bluetooth"
Thanks, this made it all work. I had to restart the script a couple of times and also restart my app, but then it worked. I will update you or create a new thread if something else comes in.
Thank you for letting us know rbulha’s suggestion resolved your issue. If you have any other questions don’t hesitate to post in the community, we’d be happy to help.