I have a couple of mobile devices that also support Bluetooth connectivity, and after some searching on the Internet I have found out how to establish a connection with these devices from my laptop in Linux, and also assign them an IP address. Basically really quick the steps involved are:
hciconfig hci0 up
hcitool scan
pand --connect MAC_ADDRESS
ifconfig bnep0 192.168.100.100 netmask 255.255.255.0
After performing these steps I can successfully ping the device with "MAC_ADDRESS" at 192.168.100.101, as well as establish SSH and SFTP connections. The problem is that I want to create a piece of code in C that does all this automatically whenever a device is in range. One way to do this is to use the system function in C, execute the previous mentioned commands, redirect their output in files, parse the files, etc. Actually I have already implemented this but it looks really bad coding from my point of view, not to mention inefficient (having to read/write from files all the time). So my question is, can I do something like that using a library available for C in Linux? Main features I want is:
- Discovery of new BT devices in range, in frequent intervals
- Establish of connection when such a device is found
- Data exchange between the two devices as long as they are in range
Thanks for your help.
Start Free Trial