Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux Bluetooth programming in c

I am trying to run a basic code of c in linux[ubuntu] to search bluetooth device, but i am facing some problem.

By using command sudo apt-get install bluez, to install required blueZ library it is saying that bluez is already newest version.

But error comes that not able to find bluetooth.h and other files in compiling C source code, with gcc -o simplescan simplescan.c -lbluetooth

Is there a complete library package, or do I have to download these header files?.

I am following this link

like image 557
Himanshu Pradhan Avatar asked Jul 10 '12 07:07

Himanshu Pradhan


People also ask

What programming language is used for Bluetooth?

While Bluetooth hardware has advanced, there has been no standardized way to develop Bluetooth applications - until JSR 82 came into play. It is the first open, non-proprietary standard for developing Bluetooth applications using the Java programming language.

How do I set up Bluetooth on Linux?

Open the Activities overview and start typing Bluetooth. Click on Bluetooth to open the panel. Make sure Bluetooth is enabled: the switch at the top should be set to on. With the panel open and the switch on, your computer will begin searching for devices.

How use BlueZ Linux?

Install BlueZ on Linux Install BlueZ packages by using any of the following commands that matches your Linux distribution. This installation provides the bluetoothctl utility. You need to add your account to the lp group if you wish to connect to a bluetooth tether. The bluetooth device should be started and enabled.


2 Answers

This solved my problem:

apt-get install libbluetooth-dev 
like image 146
Viktor Bliakhovskyi Avatar answered Sep 19 '22 10:09

Viktor Bliakhovskyi


As for i know there no packages for these headers. You have to download the following header files from internet.

  1. bluetooth.h
  2. hci.h
  3. hci_lib.h

and create a directory called "bluetooth" under /usr/lib/ in your host machine and copy the above headers to /usr/lib/bluetooth/. Then compile your program, it should work.

Note: while compiling link with -lbluetooth

like image 25
Sathish Avatar answered Sep 19 '22 10:09

Sathish