蓝牙 SDP - sdpd 在哪里?
Bluetooth SDP - where is sdpd?
蓝牙服务发现协议 (SDP) 守护程序在哪里?
我正在尝试使用 bluez 在 Debian V8.0 上注册蓝牙服务。我在 https://people.csail.mit.edu/albert/bluez-intro/ 使用示例代码。一切顺利,直到我尝试
sdp_connect( BDADDR_ANY, BDADDR_LOCAL, 0 );
失败了。经过一番挖掘,我发现 sdp 守护进程 (sdpd)(它需要连接到它)不是 运行,实际上我的系统上什至不存在。
我尝试了什么:
- 我已经安装了 (apt-get) 每个似乎远程相关但仍然没有 sdpd 的蓝牙或 bluez 包。
- 我尝试使用我的 Android phone 的地址进行连接(使用相同的代码)。这工作正常,但当然没有用。
- 对问题进行了详尽的 Google 搜索,但没有找到明确的答案。很多关于 hcid、pand 等的讨论,但没有关于它们如何相关的明确答案。
我的目标:
我正在尝试在我的 Debian 系统上注册我的服务,以便我可以从另一个蓝牙设备(特别是我的 Android)连接到它。该服务运行得很好,只是没有 SDP 注册就无法找到它。
我很乐意直接连接到它,使用它的(已知)频道号,但是 Android 只能通过注册的服务 UUID 连接(即,使用 BluetoothDevice.createRfcommSocketToServiceRecord(uuid)
),但是我看不到 API 可以连接到 频道 。
有趣的是,我可以通过频道号连接到Android上的服务,但反过来不行.我认为 sdpd 可能已经过时了 - 所有对它的引用都已有好几年了。
不确定这是否对您有帮助,但可能值得一试。我在使用 Debian 8 蓝牙时也遇到了一些问题;我通过启用 Debian 向后移植并下载 blueman
的最新向后移植版本解决了我的问题。为此,首先卸载您当前的蓝牙包(主要包,例如 bluez
),然后将此行(或类似行)添加到您的 /etc/apt/sources.list
deb http://ftp.debian.org/debian jessie-backports main contrib non-free
deb-src http://ftp.debian.org/debian jessie-backports main contrib non-free
然后运行一个apt-get update
并安装向后移植版本。我建议使用以下代码来确保配置文件更新到最新版本:
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qy -o DPkg::options::="--force-confnew" -t jessie-backports install blueman
重新启动您的计算机,看看它现在是否正常工作。注意:在 Debian 上启用 backports 不会安装可用软件的所有 backport 版本(您也不想那样)。只有当您特别要求向后移植版本时(就像我们上面所做的那样),它才会被安装。所有其他软件包将保持原样(稳定)。更新时,你的 backport 包将更新为最新的 backport 版本,你的稳定包将更新为最新的稳定版本。
编辑:编辑此答案以添加一些增强功能和信息。
[已解决] 显然,sdpd 早已不复存在。它的功能已经被bluetoothd 包含。要使其工作,请使用 --compat 标志,例如
bluetoothd --compat
这应该添加到“/etc/init.d/bluetooth”。
这样,我就可以成功连接并注册我的服务了。
我在一篇博文中找到了这方面的提示。为什么发行说明或地球上的其他任何东西从未宣布这一点,我不知道。
来自官方bluez project site:
The BlueZ 5 D-Bus API contains significant changes compared to BlueZ
4. The bulk of the changes are due to the following features in BlueZ 5:
- Transformation to use standard D-Bus Properties and ObjectManager interfaces (available in the D-Bus specification document)
- Introduction of interface versions (e.g. org.bluez.Adapter1). When new versions are introduced we’ll try to keep supporting at least the
two latest versions simultaneously.
- The simplification or removal of per-profile interfaces and the addition of a general org.bluez.Device1.Connect method to connect
profiles.
- The removal of the org.bluez.Service interface (used for registering SDP records and authorization) and the introduction of a new
org.bluez.Profile1 interface
- Dynamic device object creation during device discovery
- Introduction of an AgentManager1 interface
- Base path moved to “/org/bluez”. This shouldn’t make much difference though as the main entry point to any interaction through D-Bus is the
ObjectManager.GetManagedObjects call.
简而言之,从 Bluez5 开始,您不能使用 sdp_connect() 之类的函数。 您必须使用 D-Bus。在上面链接的页面中,您还可以找到以下内容:
BlueZ 5 introduces a new generic D-Bus interface for implementing
external profiles. The profile (residing in a separate process)
implements a org.bluez.Profile1 interface and registers an object
implementing it through a new ProfileManager1 interface on the BlueZ
side. In the RegisterProfile method (on the ProfileManager1 interface)
the profile needs to at least provide the UUID for the profile to be
registered. BlueZ has internally a table of defaults for common
profiles so no other information is necessarily needed. However, if
the profile desires to it can provide information such as the full SDP
record (XML encoded), desired security level, enable/disable
authorization, version, features, role, name, etc.
...还有很多宝贵的资料
请不要使用兼容模式(我指的是“--compat”选项)。您应该仅将其用于测试和开发:
commit 83b21cc152186f12f8bc76b7aec3107e220d5219
Author: Marcel Holtmann <marcel@holtmann.org>
Date: Mon Dec 17 14:02:59 2012 +0100
core: Hide /var/run/sdp support behind command line option
By default /var/run/sdp support has been disabled from now on. It is not
the preferred way of handling SDP records. For testing and development
purposes it can be switched back on via --compat command line option.
最后但同样重要的是,这里有一组有用的链接,可以帮助新 users/developers 使用 Bluez5:
蓝牙服务发现协议 (SDP) 守护程序在哪里?
我正在尝试使用 bluez 在 Debian V8.0 上注册蓝牙服务。我在 https://people.csail.mit.edu/albert/bluez-intro/ 使用示例代码。一切顺利,直到我尝试
sdp_connect( BDADDR_ANY, BDADDR_LOCAL, 0 );
失败了。经过一番挖掘,我发现 sdp 守护进程 (sdpd)(它需要连接到它)不是 运行,实际上我的系统上什至不存在。
我尝试了什么:
- 我已经安装了 (apt-get) 每个似乎远程相关但仍然没有 sdpd 的蓝牙或 bluez 包。
- 我尝试使用我的 Android phone 的地址进行连接(使用相同的代码)。这工作正常,但当然没有用。
- 对问题进行了详尽的 Google 搜索,但没有找到明确的答案。很多关于 hcid、pand 等的讨论,但没有关于它们如何相关的明确答案。
我的目标:
我正在尝试在我的 Debian 系统上注册我的服务,以便我可以从另一个蓝牙设备(特别是我的 Android)连接到它。该服务运行得很好,只是没有 SDP 注册就无法找到它。
我很乐意直接连接到它,使用它的(已知)频道号,但是 Android 只能通过注册的服务 UUID 连接(即,使用 BluetoothDevice.createRfcommSocketToServiceRecord(uuid)
),但是我看不到 API 可以连接到 频道 。
有趣的是,我可以通过频道号连接到Android上的服务,但反过来不行.我认为 sdpd 可能已经过时了 - 所有对它的引用都已有好几年了。
不确定这是否对您有帮助,但可能值得一试。我在使用 Debian 8 蓝牙时也遇到了一些问题;我通过启用 Debian 向后移植并下载 blueman
的最新向后移植版本解决了我的问题。为此,首先卸载您当前的蓝牙包(主要包,例如 bluez
),然后将此行(或类似行)添加到您的 /etc/apt/sources.list
deb http://ftp.debian.org/debian jessie-backports main contrib non-free
deb-src http://ftp.debian.org/debian jessie-backports main contrib non-free
然后运行一个apt-get update
并安装向后移植版本。我建议使用以下代码来确保配置文件更新到最新版本:
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qy -o DPkg::options::="--force-confnew" -t jessie-backports install blueman
重新启动您的计算机,看看它现在是否正常工作。注意:在 Debian 上启用 backports 不会安装可用软件的所有 backport 版本(您也不想那样)。只有当您特别要求向后移植版本时(就像我们上面所做的那样),它才会被安装。所有其他软件包将保持原样(稳定)。更新时,你的 backport 包将更新为最新的 backport 版本,你的稳定包将更新为最新的稳定版本。
编辑:编辑此答案以添加一些增强功能和信息。
[已解决] 显然,sdpd 早已不复存在。它的功能已经被bluetoothd 包含。要使其工作,请使用 --compat 标志,例如
bluetoothd --compat
这应该添加到“/etc/init.d/bluetooth”。 这样,我就可以成功连接并注册我的服务了。
我在一篇博文中找到了这方面的提示。为什么发行说明或地球上的其他任何东西从未宣布这一点,我不知道。
来自官方bluez project site:
The BlueZ 5 D-Bus API contains significant changes compared to BlueZ 4. The bulk of the changes are due to the following features in BlueZ 5:
- Transformation to use standard D-Bus Properties and ObjectManager interfaces (available in the D-Bus specification document)
- Introduction of interface versions (e.g. org.bluez.Adapter1). When new versions are introduced we’ll try to keep supporting at least the two latest versions simultaneously.
- The simplification or removal of per-profile interfaces and the addition of a general org.bluez.Device1.Connect method to connect profiles.
- The removal of the org.bluez.Service interface (used for registering SDP records and authorization) and the introduction of a new org.bluez.Profile1 interface
- Dynamic device object creation during device discovery
- Introduction of an AgentManager1 interface
- Base path moved to “/org/bluez”. This shouldn’t make much difference though as the main entry point to any interaction through D-Bus is the ObjectManager.GetManagedObjects call.
简而言之,从 Bluez5 开始,您不能使用 sdp_connect() 之类的函数。 您必须使用 D-Bus。在上面链接的页面中,您还可以找到以下内容:
BlueZ 5 introduces a new generic D-Bus interface for implementing external profiles. The profile (residing in a separate process) implements a org.bluez.Profile1 interface and registers an object implementing it through a new ProfileManager1 interface on the BlueZ side. In the RegisterProfile method (on the ProfileManager1 interface) the profile needs to at least provide the UUID for the profile to be registered. BlueZ has internally a table of defaults for common profiles so no other information is necessarily needed. However, if the profile desires to it can provide information such as the full SDP record (XML encoded), desired security level, enable/disable authorization, version, features, role, name, etc.
...还有很多宝贵的资料
请不要使用兼容模式(我指的是“--compat”选项)。您应该仅将其用于测试和开发:
commit 83b21cc152186f12f8bc76b7aec3107e220d5219
Author: Marcel Holtmann <marcel@holtmann.org>
Date: Mon Dec 17 14:02:59 2012 +0100
core: Hide /var/run/sdp support behind command line option
By default /var/run/sdp support has been disabled from now on. It is not
the preferred way of handling SDP records. For testing and development
purposes it can be switched back on via --compat command line option.
最后但同样重要的是,这里有一组有用的链接,可以帮助新 users/developers 使用 Bluez5: