Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
1,236 Views

Discover bluetooth devices (beacons) on the Intel Edison module?

Greetings.

I would like to know if there is anyway to discover bluetooth devices (beacons for instance, iBeacon/Eddystone) "programmatically", or automatically. So far I have used the bluetoothctl to scan and discover for instance my Android phone, which I successfully paired with. The idea is to let the Intel Edison module discover beacons and then propagate this trigger to for instance an Android app. The communication between the module and phone is already working, but the scanning for beacons is missing.

I was thinking that maybe there is a way to do this with Python?

All help is greatly appreciated!

6 Replies
Highlighted
Community Manager
25 Views

Hello zettez,

 

 

If you would like to use Python to interact with BLE devices (such as beacons), you could use pygattlib ( https://bitbucket.org/OscarAcena/pygattlib). You will need to install boost and gatttool as pygattlib depends on them. I suggest you to follow the instructions provided by Charlie in https://communities.intel.com/message/396737# 396737 https://communities.intel.com/message/396737# 396737 in order to install pygattlib and its dependencies.

 

 

I hope this information helps you, I'll be glad to help if otherwise.

 

-Peter.
0 Kudos
Highlighted
New Contributor I
25 Views

Thank you, but I cannot get this to work. I did follow the guides how to install the boost and gatttool, but when I try to run some code from the sample page:

from gattlib import DiscoveryService

service = DiscoveryService("hci0")

devices = service.discover(2)

for address, name in devices.items():

print("name: {}, address: {}".format(name, address))

Then I get this error:

root@edison:/home/bluetooth# python discovertest.py

Traceback (most recent call last):

File "discovertest.py", line 1, in

from gattlib import DiscoveryService

ImportError: libboost_python.so.1.58.0: cannot open shared object file: No such file or directory

It looks like the boost library did not get installed correctly?

0 Kudos
Highlighted
Community Manager
25 Views

Hi zettez,

I'm currently installing boost, as soon as I finish I will install gatttool and pygattlib. I will try to replicate the issue. I will update you once it finishes installing.

-Peter.

0 Kudos
Highlighted
Community Manager
25 Views

Hi zettez,

 

 

These are the steps I took to correctly install pygattlib:

 

 

wget http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz

 

tar -zxf boost_1_58_0.tar.gz

 

cd boost_1_58_0/

 

./bootstrap.sh

 

./b2 install

 

cd

 

wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.24.tar.xz --no-check-certificate

 

tar -xf bluez-5.24.tar.xz

 

cd bluez-5.24

 

./configure --disable-systemd --disable-udev

 

make

 

make install

 

cd

 

pip install gattlib

 

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/

 

 

After this I was able to run the following code without any issues:

 

 

from gattlib import DiscoveryService

 

 

service = DiscoveryService("hci0")

 

devices = service.discover(2)

 

 

for address, name in devices.items():

 

print("name: {}, address: {}".format(name, address))

 

 

Let me know if this helps you.

 

-Peter.
0 Kudos
Highlighted
New Contributor I
25 Views

I am sorry for all the edits, I successfully made it all work in the end.

Thanks for all the information.

Some notes how I made this all work:

* The environment "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ " is super important. I never saw this one in any other guide. Having this in my path fixed the boost problem. It should really, really be added in the other post you linked to me.

* After I reflashed I had to do the "rfkill unblock bluetooth" to enable bluetooth

Again, I want to thank you for the help!

0 Kudos
Highlighted
Community Manager
25 Views

Hi zettez,

 

 

I'm glad to be of help, if you ever have any other doubt, please don't hesitate to come back to the community.

 

 

-Peter.
0 Kudos