Read man hcitool bluetoothd bluetoothctl;man -k bluetooth;man -k bluez.
If you find one with functions you like, take advantage of the Open Source nature of GNU/Linux!
An example, for hcitool:
# Don't do this in your $HOME, each package should have its own subdirectory
# determine the package containg the executable
dpkg -S "$(type -p hcitool)"
pkg="$(dpkg -S "$(type -p hcitool) | head -n 1 | cut '-d:' -f1)"
# Retrieve the source
apt-get source "$pkg"
/bin/ls -l "${pkg}*"
Here's an explanation of what can be done with the "source".
In general, this process is called "building from source", and goes like this (assuming you have done sudo apt install build-essential):
- Download (
apt-get source ...) the archive (the .tar.gz). Put the file somewhere you can write, and on a filesystem with enough space. In the end, this file is disposable.
- Inspect the archive (
tar tzvf ..., see man tar). Most unpack into a subdirectory. For the few that don't, mkdir your own subdirectory, mv the .tar.gz into it, and cd there.
- Unpack the archive (
tar xzvf ...).
- Read the files with all upper case names (
README*, INSTALL, ... ). They contain complete instructions, and override anything I type after this. Read the source (usually ./src/*) to understand the program.
- If there's a
configure script, run it (./configure). configure takes many options, see the INSTALL file or ./configure -h. If configure succeeds, it will construct a Makefike.
make compiles and links what is necessary. It produces an executable that can be tested before installation.
- This is the only step requiring
root privileges: sudo make install. This command copies the executable, man pages, run-time necessities, to the "right" places.
- Once
sudo make install has worked, the whole source directory is redundant, and may be deleted.
As always, YMMV.
Explore http://www.bluez.org/