Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
1,920 Views

Programming Bluetooth with C - Where Are the BT Header Files?

I have in front of me what looks like an interesting example of Bluetooth socket programming in C that I would really like to explore:

https://people.csail.mit.edu/albert/bluez-intro/c404.html Bluetooth programming in C with BlueZ

I would really like to build this thing and give it a try but GCC can't find:

# include

# include

# include

Neither can I, and I have spent the afternoon trying. Not all afternoon, the other part of the afternoon what spent trying to find out how to locate and install the bluetooth development files which are supposed to contain said header files.

Note: Someone in a Linux form, addressing another member with the same problem, suggested that trying to import the library using the "sudo apt-get" command. Is it just me, or is "apt-get" not recognized under this linux? ("uname -r" says it is "3.10.98-poky-edison").

I have spent a considerable chunk of time getting the python "SPP-loopbak" program sort of working over the past few days, but I was looking for alternatives because I am finding that bluetooth virtual COM ports are extremely grouchy in Windows (and I have no choice of host interface, I must support all Windows version from 7 to 10). I had it working on my desktop (Window 7) but my laptop running 8.1 just would not open that port, no way, no how.

Ultimately, I need a reliable Bluetooth connection between Windows and Edison and I will not be using Python. I will be using C and C++. I will not be treating this connection like some kind of advanced human interface device or multi-media thing. Once a connection is established, every byte between host and Edison will be under program control.

Thank you,

Mark

0 Kudos
11 Replies
Highlighted
Community Manager
125 Views

Hi Mark,

 

 

Thanks for reaching out!

 

 

Thanks for all the information provided. First, I would like to let you know that the Yocto image doesn't use "apt-get", so it will not be recognized, you can use opkg instead.

 

 

Moreover, in order to compile the code example you can use this command in the Linux terminal: gcc -o my_code.c my_code –lbluetooth, using –lbluetooth will allow GCC to find the library header files.

 

 

Hope this information helps.

 

 

Regards,

 

-Yermi A.

 

0 Kudos
Highlighted
Novice
125 Views

Hi Yermi:

This is exactly the command that I have been using. Here is the dump from my "make" file execution:

root@Eddy2017:/home/Experiments# make

gcc -o btsocket btsocket.c -lbluetooth

btsocket.c:5:33: fatal error: bluetooth/bluetooth.h: No such file or directory

# include

^

compilation terminated.

makefile:2: recipe for target 'btsocket' failed

make: *** [btsocket] Error 1

root@Eddy2017:/home/Experiments#

Furthermore, I have searched my Edison directories and cannot find a file called "Bluetooth.h".

Mark

0 Kudos
Highlighted
Community Manager
125 Views

Hi Mark,

 

 

I have been able to compile the code using the command line provided previously, Additionally, I found the header files in this path: /usr/include/Bluetooth/, please take a look at the screenshot below, you can also use this command to find the header files: find –name header_file_name.

 

 

Also, I would like to know which image are you using, you can use this command to know that cat /etc/version.

 

 

Hope this information helps.

 

 

Regards,

 

-Yermi A.

 

0 Kudos
Highlighted
Community Manager
125 Views

Hi Mark,

 

 

Do you have any updates? Were you able to compile the code?

 

 

Regards,

 

-Yermi A.

 

0 Kudos
Highlighted
Novice
125 Views

Hi Yermi:

The "find" command returns the following:

root@Eddy2017:/# find -name bluetooth.h

root@Eddy2017:/#

In other words, not found.

The directory: "/usr/include/bluetooth/"

does not exist.

I realize that you probably hear this a lot, but I did not delete anything from this system. I am new to Linux and Edison. I have not got a clue what any of these directories and sub-directories do. But if there is one thing I DO know in my 30 years of experience with various other operating systems, it is "don't screw around with what you don't understand." So I have not and will not start deleting directories and files that I am not sure about and I am not sure about anything on this board. To summarize, if the file is not there now, then it never was.

Mark

0 Kudos
Highlighted
Novice
125 Views

Hi Again:

In answer to your other question:

root@Eddy2017:/# cat /etc/version

201606081705

root@Eddy2017:/#

Mark

0 Kudos
Highlighted
Community Manager
125 Views

Hi Mark,

 

 

That is very strange, I have the same Edison image and those headers are already in the image. I would like to suggest you to try one of the following suggestions:

 

  1. Re-flash your Edison image (recommended): flashing the image may help to have those header files in your Edison, here you can find the instructions: https://software.intel.com/en-us/flashing-your-firmware-edison Flashing your firmware.
  2. Install Bluez5 in your Edison: take a look at the http://alextgalileo.altervista.org/edison-package-repo-configuration-instructions.html AlexT's Galileo & Edison pages for instructions to configure the Edison to fetch packages from that repo and then you can use # opkg install bluez5 to install Bluez5.

 

Hope this information helps, also, let me know if you have any questions.

 

 

Regards,

 

-Yermi A.

 

0 Kudos
Highlighted
Novice
125 Views

Hi Yermi:

I have used "opkg" on a few occassions to update various things on the Edison board. I just now typed in:

root@Eddy2017:~# opkg install bluez5

Upgrading bluez5 from 5.22-r0.0 to 5.37-r0 on root.

Downloading http://iotdk.intel.com/repos/3.5/iotdk/edison/core2-32/bluez5_5.37-r0_core2-32.ipk.

Removing obsolete file /usr/lib/libbluetooth.so.3.17.10.

Configuring bluez5.

root@Eddy2017:~#

The above looks like everyjting installed just fine.

Never the less, there is still no "/usr/include/bluetooth" directory.

and

root@Eddy2017:/# find -name bluetooth.h

root@Eddy2017:/#

Still comes up with nothing.

Mark

0 Kudos
Highlighted
Novice
125 Views

Hi Again:

When I was trying to get the bluetooth system to operate like a serial port, I ran into trouble. Are you aware that Intel Support people are telling people to roll back to V5.22 of BlueZ?

Here is the message from Pedro M:

Hello Mark,

Thanks for reaching out!

In the following thread you will find how we were able to create a SPP connection to a Windows PC:

/message/408584# 408584 https://communities.intel.com/message/408584# 408584

In that thread it is mentioned that there was an issue with SPP on images 3.0 and up. However, this was due to the BlueZ version and you will find how to fix this issue on the latest image in the following guide:

/docs/DOC-100754 https://communities.intel.com/docs/DOC-100754

I hope this information helps you,

Pedro M.

0 Kudos
Highlighted
Novice
125 Views

Hi Yermi, yet again:

OK, I reflashed the thing, which is a lot of work, given all of the settings you have to redo and MRAA libraries you have to update.

Nevertheless, the Bluetooth directory is there under "\usr\include\".

I have no idea what happened to the original one. Must have been my evil twin.

Thanks,

Mark

0 Kudos
Highlighted
Community Manager
125 Views

Hi Mark,

 

 

It is very strange that you don't have the header files before, and I also know that the flash process and make all the necessary settings may demand some extra effort, however, it is great to know that you already have them in your Edison image.

 

 

Regards,

 

-Yermi A.

 

0 Kudos