Using BlueZ_jll for bluetooth communication

I wanted to use julia for collecting some data from a bluetooth device, and couldn’t find any package for that. What I did find was the BlueZ_jll package, which seemed fit for the job.

After some figuring out how the jll packages work I found that I should be able to do

using BlueZ_jll
run(`$(bluetoothctl()) <command>`)

since bluetoothctl was exported as an executable. This seemed to be correct since I got something, but did not work fully and gave me this

dbus[2797897]: arguments to dbus_connection_get_object_path_data() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c line 5905.
This is normally a bug in some application using the D-Bus library.

  D-Bus not built with -rdynamic so unable to print a backtrace
ERROR: ...

Taking the path from bluetoothctl() and running that in my terminal works, but then it uses my local libraries. Also using the LD_LIBRARY_PATH from bluetoothctl() does not work in the terminal, and the linking then looks rather different. I’m not very used to either bluetooth or looking at linking information so I’m not really sure where to start looking for the problem.

Just running ldd in BlueZ_jll bin folder

albheim@gilbert:bin$ ldd bluetoothctl 
	linux-vdso.so.1 (0x00007fff2cfe1000)
	libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007fcc4e183000)
	libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007fcc4e131000)
	libreadline.so.8 => /lib64/libreadline.so.8 (0x00007fcc4e0d9000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fcc4df0a000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fcc4de92000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcc4de71000)
	libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007fcc4ddab000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007fcc4dd7c000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fcc4e2ef000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fcc4dd71000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fcc4dd45000)
	libzstd.so.1 => /lib64/libzstd.so.1 (0x00007fcc4dc4f000)
	liblz4.so.1 => /lib64/liblz4.so.1 (0x00007fcc4dc2b000)
	libcap.so.2 => /lib64/libcap.so.2 (0x00007fcc4dc1f000)
	libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcc4dbf3000)
	libgcrypt.so.20 => /lib64/libgcrypt.so.20 (0x00007fcc4dab7000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fcc4da9c000)
	libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fcc4da05000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fcc4d9fe000)
	libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007fcc4d9d6000)
albheim@gilbert:bin$ ./bluetoothctl list
Controller 34:E1:2D:20:C2:53 gilbert [default]

Running ldd with LD_LIBRARY_PATH updated

albheim@gilbert:bin$ export LD_LIBRARY_PATH=/local/home/albheim/.julia/artifacts/2a0fba617ae96fd7bec0e5f0981a2cc395998f08/lib:/local/home/albheim/.julia/artifacts/94eb32b3203f6059eeb8a2c299e4757acef6032f/lib:/local/home/albheim/.julia/artifacts/872754c2f795d19a3e2e205b2bbaea659f28d11e/lib:/local/home/albheim/.julia/artifacts/2e8fae88dcadc37883e31246fe7397f4f1039f88/lib:/local/home/albheim/.julia/artifacts/f1a54fe617cfa5997fa86c2cb15b93ac1d8c4c24/lib64:/local/home/albheim/git/julia/usr/bin/../lib:/local/home/albheim/.julia/artifacts/75b2da9ed2ec48588460be0f3a8bb489212012e9/lib:/local/home/albheim/.julia/artifacts/dc526f26fb179a3f68eb13fcbe5d2d2a5aa7eeac/lib:/local/home/albheim/.julia/artifacts/17314d4057d189dbe9a4cbb1dc839b541d70fc29/lib:/local/home/albheim/.julia/artifacts/5a508a62784097dab7c7ae5805f2c89d2cc97397/lib:/local/home/albheim/.julia/artifacts/e086922a5a3c20ca3e6866a33e42d8ec4689553e/lib:/local/home/albheim/.julia/artifacts/bc7df2a88972dd1ff2685e091585f5c979bfd436/lib:/local/home/albheim/.julia/artifacts/23f32b19b8e0257ec9d43322d41231533a2def1d/lib:/local/home/albheim/.julia/artifacts/1cb68e90a5ad4655378340dd08ba2274bf5961c4/lib:/local/home/albheim/.julia/artifacts/1f643b9793a1d59dc7915badbdf52ce84d016d04/lib:/local/home/albheim/.julia/artifacts/d56f6bc8675ad021bf8070a7bce573e3fbe2e737/lib:/local/home/albheim/.julia/artifacts/a018fb15c5a8f00780b0f29eae53dc659373cb87/lib:/local/home/albheim/.julia/artifacts/839a11df9d8924529ac28594bd22f510f28a7e3a/lib:/local/home/albheim/git/julia/usr/bin/../lib/julia:/local/home/albheim/git/julia/usr/bin/../lib
albheim@gilbert:bin$ ldd bluetoothctl 
	linux-vdso.so.1 (0x00007ffebbddc000)
	libglib-2.0.so.0 => /local/home/albheim/.julia/artifacts/e086922a5a3c20ca3e6866a33e42d8ec4689553e/lib/libglib-2.0.so.0 (0x00007f5c1edc3000)
	libdbus-1.so.3 => /local/home/albheim/.julia/artifacts/94eb32b3203f6059eeb8a2c299e4757acef6032f/lib/libdbus-1.so.3 (0x00007f5c1eb64000)
	libreadline.so.8 => /local/home/albheim/.julia/artifacts/a018fb15c5a8f00780b0f29eae53dc659373cb87/lib/libreadline.so.8 (0x00007f5c1e909000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f5c1e70a000)
	libpcre.so.1 => /local/home/albheim/.julia/artifacts/17314d4057d189dbe9a4cbb1dc839b541d70fc29/lib/libpcre.so.1 (0x00007f5c1e4c7000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f5c1e4bc000)
	libiconv.so.2 => /local/home/albheim/.julia/artifacts/2e8fae88dcadc37883e31246fe7397f4f1039f88/lib/libiconv.so.2 (0x00007f5c1e1bf000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5c1e19c000)
	libncursesw.so.6 => /local/home/albheim/.julia/artifacts/d56f6bc8675ad021bf8070a7bce573e3fbe2e737/lib/libncursesw.so.6 (0x00007f5c1df27000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f5c1f114000)
albheim@gilbert:bin$ ./bluetoothctl list
dbus[2809816]: arguments to dbus_connection_get_object_path_data() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c line 5905.
This is normally a bug in some application using the D-Bus library.

  D-Bus not built with -rdynamic so unable to print a backtrace
Aborted (core dumped)

Off course I could just use my local bluetoothctl, but it would be fun to put together a small package with some simpler julia bindings if I get something to work and for that it seems like the artifacts would be the way to go.

Not sure if this is just a local problem on my setup or if it is a problem with the BlueZ_jll. Any suggestions are welcome :slight_smile: