Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BlueZ: Adding services, attributes, and profiles without sdptool command

Prior to BlueZ 5, the way to add/remove Bluetooth services/attributes/profiles on Linux was done through the sdptool as follows:-

To browse local records

#sdptool browse local
Browsing FF:FF:FF:00:00:00 ...

To add a service

#sdptool add SP
Serial Port service registered

To remove a service

#sdptool del 0x10007
Service Record deleted.

However, sdptool was deprecated (along with hciattach, hciconfig, hcitool, hcidump, rfcomm, ciptool, and gatttool) and removed from the main BlueZ build as can be seen in the following links:-

  • Link 1
  • Link 2
  • Link 3

Fortunately, most of these commands have been replaced with newer ones (btattach, btmgmt, and bluetoothctl). However, there doesn't seem to be any replacement for the sdptool.

My question is:- what tool can I use now instead of sdptool in order to browse local services/profile as well as add or remove profiles?

Please note that I am aware that sdptool can be rebuilt-in and enabled, but I am searching for the replacement to the command rather than a workaround.

like image 243
Youssif Saeed Avatar asked Oct 30 '18 17:10

Youssif Saeed


1 Answers

From Bluez 5 this needs to be done using ProfileManager DBUS interface. One needs to register the custom/external profile using this interface and Bluez handles all the aspect of security and connection.

Once the connection is ready, bluez provides file descriptor to operate on for the external profile. You can find an example implementation of HFP profile in bluez-alsa.

In detail, You can implement all the methods of org.bluez.Profile1 interface and register it with Bluez using org.bluez.ProfileManager1 interface where you can specify the UUID, auth (if any needed).

In bluez-alsa,

  1. Registration is done here.
  2. Methods are implemented here.

Once the connection for this profile is established, NewConnection API is called with the fd in argument.

But AFAIK, there isn't any direct way to achieve this using existing tools like bluetoothctl.

like image 162
Parthiban Avatar answered Oct 04 '22 18:10

Parthiban