• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bluez version on netPi
#1
Hi,

I am experimenting with bluetooth low energy on the netPi. Unfortunately it is not possible to start a bluetoothd daemon inside a docker container beacuse it connects to the system dbus (The same dbus as on the docker host system) where a bluetoothd is already running. I am able to talk to the bluetoothd running on the host system when I share the dbus socket with the container but unfortunately the bluez package on the host system is outdated (5.41) and some features I need are missing. Is ist possible to install a newer/the newest bluez version?

Thank you
Thomas
  Reply
#2
Hi Armin,

I started with the netpi-raspbian image. I shared the file /var/run/dbus/system_bus_socket and use the host network in the container and started the container in privileged mode so I can connect to the bluetoothd running on the host via dbus.
Then I built the bluez-5.41 from source to match the bluez version with the one of bluetoothd running on the host.
> cd bluez_source_dir
> ./configure
> ./make

There should be a file called bluez_sorce_dir/client/bluetoothctl which also uses the bluez dbus-API as I want to used from my own application. You have to start it as root.

After powering on the bluetooth adapter
> [bluetooth]# power on
scanning for bluetooth devices
> [bluetooth]# scan on
> [NEW] Device B0:91:22:68:27:01 Name: XXX
and connecting to a bluetooth device
> [bluetooth]# connect B0:91:22:68:27:01
there should appear a list of GATT characteristics depending on the bluetooth device.

Something like this:
[CHG] Device 5C:31:3E:71:0C:E7 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 5C:31:3E:71:0C:E7 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 5C:31:3E:71:0C:E7 UUIDs: 0000180f-0000-1000-8000-00805f9b34fb
[CHG] Device 5C:31:3E:71:0C:E7 UUIDs: 0d271100-f0d4-469d-afd3-605a6ebbdb13
[CHG] Device 5C:31:3E:71:0C:E7 UUIDs: 0d27fa01-f0d4-469d-afd3-605a6ebbdb13
[CHG] Device 5C:31:3E:71:0C:E7 UUIDs: 0d27fa60-f0d4-469d-afd3-605a6ebbdb13
[CHG] Device 5C:31:3E:71:0C:E7 UUIDs: 0d27ffc0-f0d4-469d-afd3-605a6ebbdb13
[NEW] Service /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010 Vendor specific (Primary)
[NEW] Characteristic /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010/char0011 Vendor specific
[NEW] Characteristic /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010/char0013 Vendor specific
[NEW] Characteristic /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010/char0015 Vendor specific
[NEW] Characteristic /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010/char0017 Vendor specific
[NEW] Characteristic /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010/char0019 Vendor specific
[NEW] Characteristic /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010/char001b Vendor specific
[NEW] Characteristic /org/bluez/hci0/dev_5C_31_3E_71_0C_E7/service0010/char001d Vendor specific
...

You can test with a fitness-tracker or another bluetooth peripheral using GATT. Or you could use an android phone. To start a GATT server and start advertising you can use the nRF Connect for Mobile app.

With bluez-5.41 the GATT-DBUS API is still experimental and the Characteristics are not discovered because you have to compile and run the bluetoothd with experimental features enabled. I expect it to work with bluez version >= 5.43 since this feature is no longer experimental from this point. I would prefer version 5.47 because the release notes state some fixes for GATT until there.

Regards
Thomas
  Reply
#3
Hello Thomas,

I did nearly the same as you did. Use the raspbian image and installed bluez to it using apt-get install -y bluez. I started the container in priviledged mode as you did and also with host network shared, but NO host dbus shared with the container.

Entering the container with SSH I used hciconfig hci0 up and hcitool scan to test. Afterwards I tried using bluetooth -dn with debug option and it came back with /var/run/dbus/system_bus_socket: no such file error.

So I started a private dbus in the container using /etc/init.d/dbus start and then bluetoothd -dn and it starts it right away. In a second console I was able to use bluetoothctl now with the commands you proposed.

Now since this procedure let the run socket independently of the host dbus, you can now check the bluez update yourself.

Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#4
Hell Armin,

I did that before but I get this result when starting the bluetoothd:

bluetoothd[130]: Bluetooth daemon 5.47
bluetoothd[130]: src/adapter.c:adapter_init() sending read version command
bluetoothd[130]: Starting SDP server
bluetoothd[130]: binding L2CAP socket: Address already in use
bluetoothd[130]: Server initialization failed
bluetoothd[130]: src/sdpd-service.c:register_device_id() Adding device id record for 0002:1d6b:0246:052f
bluetoothd[130]: src/plugin.c:plugin_init() Loading builtin plugins
bluetoothd[130]: src/plugin.c:add_plugin() Loading hostname plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading wiimote plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading autopair plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading policy plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading a2dp plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading avrcp plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading network plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading input plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading hog plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading gap plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading scanparam plugin
bluetoothd[130]: src/plugin.c:add_plugin() Loading deviceinfo plugin
bluetoothd[130]: src/plugin.c:plugin_init() Loading plugins /usr/local/lib/bluetooth/plugins
bluetoothd[130]: profiles/input/suspend-none.cConfuseduspend_init()
bluetoothd[130]: profiles/network/manager.c:read_config() Config options: Security=true
bluetoothd[130]: src/main.c:main() Entering main loop
bluetoothd[130]: src/rfkill.c:rfkill_event() RFKILL event idx 0 type 1 op 0 soft 0 hard 0
bluetoothd[130]: Bluetooth management interface 1.14 initialized
bluetoothd[130]: src/adapter.c:read_version_complete() sending read supported commands command
bluetoothd[130]: src/adapter.c:read_version_complete() sending read index list command
bluetoothd[130]: src/rfkill.c:rfkill_event() RFKILL event idx 1 type 2 op 0 soft 0 hard 0
bluetoothd[130]: src/adapter.c:read_commands_complete() Number of commands: 65
bluetoothd[130]: src/adapter.c:read_commands_complete() Number of events: 35
bluetoothd[130]: src/adapter.c:read_commands_complete() enabling kernel-side connection control
bluetoothd[130]: src/adapter.c:read_index_list_complete() Number of controllers: 1
bluetoothd[130]: src/adapter.c:read_index_list_complete() Found index 0
bluetoothd[130]: src/adapter.c:index_added() index 0
bluetoothd[130]: src/adapter.c:btd_adapter_new() System name: BlueZ 5.47
bluetoothd[130]: src/adapter.c:btd_adapter_new() Major class: 0
bluetoothd[130]: src/adapter.c:btd_adapter_new() Minor class: 0
bluetoothd[130]: src/adapter.c:btd_adapter_new() Modalias: usb:v1D6Bp0246d052F
bluetoothd[130]: src/adapter.c:btd_adapter_new() Discoverable timeout: 180 seconds
bluetoothd[130]: src/adapter.c:btd_adapter_new() Pairable timeout: 0 seconds
bluetoothd[130]: src/adapter.c:index_added() sending read info command for index 0
bluetoothd[130]: src/adapter.c:read_info_complete() index 0 status 0x00
bluetoothd[130]: src/adapter.c:clear_uuids() sending clear uuids command for index 0
bluetoothd[130]: src/adapter.c:clear_devices() sending clear devices command for index 0
bluetoothd[130]: src/adapter.cConfusedet_privacy() sending set privacy command for index 0
bluetoothd[130]: src/adapter.cConfusedet_privacy() setting privacy mode 0x00 for index 0
bluetoothd[130]: Failed to start listening: l2cap_bind: Address already in use (98)
bluetoothd[130]: Failed to create GATT database for adapter
bluetoothd[130]: Unable to register new adapter
bluetoothd[130]: src/adapter.c:btd_adapter_unref() Freeing adapter /org/bluez/hci0
bluetoothd[130]: src/adapter.c:adapter_free() 0x16e7400

So my assumtion is that the bluetoothd running on the host somehow prevents the second bluetoothd inside the container to start.

Is there a bluetoothd running on your host?

Regards
Thomas
  Reply
#5
Well I am not using the 5.47 version, but I am getting this log output

^Croot@NTB827EB0264F7:~# bluetoothd -dn
bluetoothd[58]: Bluetooth daemon 5.23
bluetoothd[58]: src/main.c:parse_config() parsing main.conf
bluetoothd[58]: src/main.c:parse_config() Key file does not have key 'DiscoverableTimeout'
bluetoothd[58]: src/main.c:parse_config() Key file does not have key 'PairableTimeout'
bluetoothd[58]: src/main.c:parse_config() Key file does not have key 'AutoConnectTimeout'
bluetoothd[58]: src/main.c:parse_config() Key file does not have key 'Name'
bluetoothd[58]: src/main.c:parse_config() Key file does not have key 'Class'
bluetoothd[58]: src/main.c:parse_config() Key file does not have key 'DeviceID'
bluetoothd[58]: src/main.c:parse_config() Key file does not have key 'ReverseServiceDiscovery'
bluetoothd[58]: src/gatt.c:gatt_init() Starting GATT server
bluetoothd[58]: src/adapter.c:adapter_init() sending read version command
bluetoothd[58]: Starting SDP server
bluetoothd[58]: binding L2CAP socket: Address already in use
bluetoothd[58]: Server initialization failed
bluetoothd[58]: src/sdpd-service.c:register_device_id() Adding device id record for 0002:1d6b:0246:0517
bluetoothd[58]: src/plugin.c:plugin_init() Loading builtin plugins
bluetoothd[58]: src/plugin.c:add_plugin() Loading hostname plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading wiimote plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading autopair plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading policy plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading neard plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading sap plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading a2dp plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading avrcp plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading network plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading input plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading hog plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading health plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading gatt plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading scanparam plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading deviceinfo plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading alert plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading time plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading proximity plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading thermometer plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading heartrate plugin
bluetoothd[58]: src/plugin.c:add_plugin() Loading cyclingspeed plugin
bluetoothd[58]: src/plugin.c:plugin_init() Loading plugins /usr/lib/arm-linux-gnueabihf/bluetooth/plugins
bluetoothd[58]: profiles/health/hdp.c:hdp_manager_start() Starting Health manager
bluetoothd[58]: profiles/input/suspend-dummy.cConfuseduspend_init()
bluetoothd[58]: profiles/input/suspend-dummy.cConfuseduspend_init() Created suspend-dummy FIFO on /run/hogsuspend
bluetoothd[58]: profiles/network/manager.c:read_config() /etc/bluetooth/network.conf: Key file does not have key 'DisableSecurity'
bluetoothd[58]: profiles/network/manager.c:read_config() Config options: Security=true
bluetoothd[58]: plugins/neard.c:neard_init() Setup neard plugin
bluetoothd[58]: src/main.c:main() Entering main loop
bluetoothd[58]: src/rfkill.c:rfkill_event() RFKILL event idx 0 type 1 op 0 soft 0 hard 0
bluetoothd[58]: Bluetooth management interface 1.14 initialized
bluetoothd[58]: src/adapter.c:read_version_complete() sending read supported commands command
bluetoothd[58]: src/adapter.c:read_version_complete() sending read index list command
bluetoothd[58]: src/rfkill.c:rfkill_event() RFKILL event idx 1 type 2 op 0 soft 0 hard 0
bluetoothd[58]: src/adapter.c:read_commands_complete() Number of commands: 65
bluetoothd[58]: src/adapter.c:read_commands_complete() Number of events: 35
bluetoothd[58]: src/adapter.c:read_commands_complete() enabling kernel-side connection control
bluetoothd[58]: src/adapter.c:read_index_list_complete() Number of controllers: 1
bluetoothd[58]: src/adapter.c:read_index_list_complete() Found index 0
bluetoothd[58]: src/adapter.c:index_added() index 0
bluetoothd[58]: src/adapter.c:btd_adapter_new() System name: BlueZ 5.23
bluetoothd[58]: src/adapter.c:btd_adapter_new() Major class: 0
bluetoothd[58]: src/adapter.c:btd_adapter_new() Minor class: 0
bluetoothd[58]: src/adapter.c:btd_adapter_new() Modalias: usb:v1D6Bp0246d0517
bluetoothd[58]: src/adapter.c:btd_adapter_new() Discoverable timeout: 180 seconds
bluetoothd[58]: src/adapter.c:btd_adapter_new() Pairable timeout: 0 seconds
bluetoothd[58]: src/adapter.c:index_added() sending read info command for index 0
bluetoothd[58]: src/adapter.c:read_info_complete() index 0 status 0x00
bluetoothd[58]: src/adapter.c:clear_uuids() sending clear uuids command for index 0
bluetoothd[58]: src/adapter.c:clear_devices() sending clear devices command for index 0
bluetoothd[58]: src/attrib-server.c:btd_adapter_gatt_server_start() Start GATT server in hci0
bluetoothd[58]: l2cap_bind: Address already in use (98)
bluetoothd[58]: profiles/audio/a2dp.c:media_server_probe() path /org/bluez/hci0
bluetoothd[58]: plugins/hostname.c:hostname_probe()
bluetoothd[58]: Not enough free handles to register service
bluetoothd[58]: Error adding Link Loss service
bluetoothd[58]: Not enough free handles to register service
bluetoothd[58]: Not enough free handles to register service
bluetoothd[58]: profiles/proximity/reporter.c:reporter_adapter_probe() Proximity Reporter for adapter 0x55eb2900
bluetoothd[58]: profiles/time/server.c:time_server_init() path /org/bluez/hci0
bluetoothd[58]: Not enough free handles to register service
bluetoothd[58]: Current Time Service could not be registered
bluetoothd[58]: gatt-time-server: Input/output error (5)
bluetoothd[58]: Not enough free handles to register service
bluetoothd[58]: Not enough free handles to register service
bluetoothd[58]: Failed to listen on control channel
bluetoothd[58]: input-hid: Operation not permitted (1)
bluetoothd[58]: profiles/network/manager.c:panu_server_probe() path /org/bluez/hci0
bluetoothd[58]: l2cap_bind: Address already in use (98)
bluetoothd[58]: network-panu: Invalid argument (22)
bluetoothd[58]: profiles/network/manager.c:gn_server_probe() path /org/bluez/hci0
bluetoothd[58]: l2cap_bind: Address already in use (98)
bluetoothd[58]: network-gn: Invalid argument (22)
bluetoothd[58]: profiles/network/manager.c:nap_server_probe() path /org/bluez/hci0
bluetoothd[58]: l2cap_bind: Address already in use (98)
bluetoothd[58]: network-nap: Invalid argument (22)
bluetoothd[58]: profiles/audio/avrcp.c:avrcp_controller_server_probe() path /org/bluez/hci0
bluetoothd[58]: l2cap_bind: Address already in use (98)
bluetoothd[58]: avrcp-controller: Protocol not supported (93)
bluetoothd[58]: profiles/audio/avrcp.c:avrcp_target_server_probe() path /org/bluez/hci0
bluetoothd[58]: l2cap_bind: Address already in use (98)
bluetoothd[58]: audio-avrcp-target: Protocol not supported (93)
bluetoothd[58]: profiles/audio/a2dp.c:a2dp_sink_server_probe() path /org/bluez/hci0
bluetoothd[58]: profiles/audio/a2dp.c:a2dp_source_server_probe() path /org/bluez/hci0
bluetoothd[58]: profiles/sap/manager.cConfusedap_server_probe() path /org/bluez/hci0
bluetoothd[58]: Sap driver initialization failed.
bluetoothd[58]: sap-server: Operation not permitted (1)
bluetoothd[58]: src/adapter.c:btd_adapter_unblock_address() hci0 00:00:00:00:00:00
bluetoothd[58]: src/adapter.c:load_link_keys() hci0 keys 0 debug_keys 0
bluetoothd[58]: src/adapter.c:load_ltks() hci0 keys 0
bluetoothd[58]: src/adapter.c:load_irks() hci0 irks 0
bluetoothd[58]: src/adapter.c:load_conn_params() hci0 conn params 0
bluetoothd[58]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[58]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[58]: src/adapter.cConfusedet_did() hci0 source 2 vendor 1d6b product 246 version 517
bluetoothd[58]: src/adapter.c:adapter_register() Adapter /org/bluez/hci0 registered
bluetoothd[58]: src/adapter.cConfusedet_dev_class() sending set device class command for index 0
bluetoothd[58]: src/adapter.cConfusedet_name() sending set local name command for index 0
bluetoothd[58]: src/adapter.c:load_link_keys_complete() link keys loaded for hci0
bluetoothd[58]: src/adapter.c:load_ltks_complete() LTKs loaded for hci0
bluetoothd[58]: src/adapter.c:load_irks_complete() IRKs loaded for hci0
bluetoothd[58]: src/adapter.c:load_conn_params_complete() Connection Parameters loaded for hci0
bluetoothd[58]: src/adapter.c:local_name_changed_callback() Name: BlueZ 5.23
bluetoothd[58]: src/adapter.c:local_name_changed_callback() Short name:
bluetoothd[58]: src/adapter.c:local_name_changed_callback() Current alias: BlueZ 5.23
bluetoothd[58]: plugins/hostname.c:property_changed() static hostname: NTB827EB0264F7
bluetoothd[58]: plugins/hostname.c:property_changed() pretty hostname:
bluetoothd[58]: plugins/hostname.c:update_name() name: NTB827EB0264F7
bluetoothd[58]: src/adapter.c:adapter_set_name() name: NTB827EB0264F7
bluetoothd[58]: src/adapter.c:adapter_set_name() alias: NTB827EB0264F7
bluetoothd[58]: src/adapter.cConfusedet_name() sending set local name command for index 0
bluetoothd[58]: plugins/hostname.c:property_changed() chassis:
bluetoothd[58]: src/adapter.c:local_name_changed_callback() Name: NTB827EB0264F7
bluetoothd[58]: src/adapter.c:local_name_changed_callback() Short name:
bluetoothd[58]: src/adapter.c:local_name_changed_callback() Current alias: NTB827EB0264F7

And in a second console this

root@NTB827EB0264F7:~# bluetoothctl
[NEW] Controller B8:27:EB:A8:CE:5D NTB827EB0264F7 [default]
[bluetooth]# power on
Changing power on succeeded
[CHG] Controller B8:27:EB:A8:CE:5D Powered: yes
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:A8:CE:5D Discovering: yes
[NEW] Device 48:92Big Grin0:62:2C:A7 48-92-D0-62-2C-A7
[NEW] Device 00:1A:E8:2F:75:38 00-1A-E8-2F-75-38
[CHG] Device 00:1A:E8:2F:75:38 LegacyPairing: no
[CHG] Device 00:1A:E8:2F:75:38 Name: OpenStage 00:1A:E8:2F:75:38
[CHG] Device 00:1A:E8:2F:75:38 Alias: OpenStage 00:1A:E8:2F:75:38
[CHG] Device 48:92Big Grin0:62:2C:A7 RSSI: -83
[bluetooth]#

And I asked the development team. We have no bluetoothd daemon running.
rfkill list on the host delivers

0: phy0: wlan
Soft blocked: no
Hard blocked: no
1: hci0: bluetooth
Soft blocked: no
Hard blocked: no

and the command
lsof | grep ttyAMA0
delivers
780 /usr/bin/hciattach /dev/ttyAMA0

which is ok and creates the hci0 using the hciattach command




You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#6
Hello,

I deleted the bluez package in the control panel in order to stop the bluetoothd on the host, but now the hci0 device is completely gone. Is there a way to get the package to reinstall it?

Regards
Thomas
  Reply
#7
Hello Thomas,

can you tell me in which version of bluez you are looking at? At kernel.org I see the versions going up to 5.9 meanwhile while bluez.org just lists versions up to 5.47.
Let me check with the development team which options we have. In general every installed package on netPI can be updated separately using the Packages option in netPI's management web UI in conjunction with the corresponding Hilscher signed package file.
Do you have also a code snippet to check what do did so far or a Docker file to get it reconstucted here?

Thx
Armin

You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#8
Hi Armin,

there must have been a bluetoothd running on my device because otherwise I could not have talked to it via the shared dbus socket. Only bluetoothd creates the well known dbus-name "org.bluez" and I did not run it in the container.

Regards
Thomas
  Reply
#9
Thomas, your are right. I took my debug netPI now and indeed there is a bluetoothd service started by the Linux host.

After discussing this issue with the development team we came to the common decision that starting the service on the host makes no sense and needs to be removed in the next image version. With Wifi this is different since

If I stop the service on the host I am not getting "binding L2CAP socket: Address already in use" message any longer in the container.





You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#10
Hi Armin,

when I try to install the bluez5_5.41-r0.0_armhf.deb package the Control Panel sais "Failed to install...". When will the next netPi image without bluetoothd be available and is there a factory image to get my netPi back to factory state?

Regards,
Thomas
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Raspbian OS version of the latest hilschernetpi/netpi-raspbian tad 2 2,257 March-5th-2021, 11:25 AM
Last Post: tad
  BLE pairing problems with bluez 5.50 abmn 1 4,242 August-8th-2019, 08:51 AM
Last Post: Armin@netPI

Forum Jump:


Users browsing this thread: 1 Guest(s)