ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Bluetooth in a ROS package

asked 2016-11-12 18:17:22 -0500

farhansajjad gravatar image

Hi, I'm new in the ROS world. I just wanna know how I can use Bluetooth in a ROS package. I added Bluetooth libraries in the source file by:

#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

and then I tried to retrieve the resource number to open the socket by:

dev_id = hci_get_route(NULL);
sock = hci_open_dev( dev_id );

but when I try to build this package I got errors saying:

undefined reference to `hci_get_route'

undefined reference to `hci_open_dev'

so this means the Bluetooth library is still not included. How I can add this? Any help will be appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-11-12 18:23:47 -0500

ahendrix gravatar image

You're including the right headers, but you also need to tell the compiler to link against the bluetooth library.

In CMake, you can link against libraries with the target_link_libraries command:

target_link_libraries(my_target bluetooth)

(you'll need to replace my_target with the name of your target)

This is the equivalent of passing -lbluetooth to the compiler when building with gcc manually.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-11-12 18:17:22 -0500

Seen: 1,654 times

Last updated: Nov 12 '16