[英]How to register connection callbacks with Bluez Profile1 DBus API
[英]Updated Bluez DBUS-API document?
我只是嘗試運行一個 vala bluez 示例(在DbusClientSamples頁面中找到),但出現此錯誤:
GDBus.Error:org.freedesktop.DBus.Error.UnknownObject:
Method "DiscoverDevices" with signature "" on interface "org.bluez.Adapter"
doesn't exist
示例是否使用已棄用的 API? 如果是,我在哪里可以找到關於 bluez 的 DBUS API 的更新文檔? 我找到的所有文檔(通過谷歌搜索)都包含DiscoverDevices
方法,所以我很困惑。
AFAICT org.bluez.Adapter 不見了(我在運行 bluez-5.12 的 Fedora 20 系統上沒有看到它)。 取而代之的是org.bluez.Adapter1 。 您可以在https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc 上獲取 bluez D-Bus API 的所有最新文檔
獲取 BlueZ DBus 文檔的最佳方式是從BlueZ 網站下載源代碼,解壓縮,然后在doc
目錄中查找。 所有當前的 DBus API 都列在那里。
我最近經常使用這些文件。 你可以要求更好,但他們已經足夠好了。 這是最明顯的,並且解釋了最不明顯的問題。
BlueZ官方站點還提供了BlueZ 5 API 介紹和移植指南的博客文章,其中提供了有關其 DBus API 的一些描述。 他們在頁面頂部寫道:
與 BlueZ 4 相比,BlueZ 5 D-Bus API 包含重大更改。大部分更改是由於 BlueZ 5 中的以下功能:
- ...
- 接口版本介紹(例如
org.bluez.Adapter1
)。 當引入新版本時,我們將嘗試同時支持至少兩個最新版本。- ...
有一節討論了 DBus 對象管理器:
相反,應用程序將通過執行
ObjectManager.GetManagedObjects
調用來發現可用的適配器,並使用“org.bluez.Adapter1
”接口查找任何返回的對象。
此外,除了查看 BlueZ 源代碼的docs
目錄(如this和this答案中所述),我發現檢查test
目錄中的示例源代碼也很有幫助( https://git.kernel.org /pub/scm/bluetooth/bluez.git/tree/test )。
以下是示例廣告代碼的一部分:
BLUEZ_SERVICE_NAME = 'org.bluez'
LE_ADVERTISING_MANAGER_IFACE = 'org.bluez.LEAdvertisingManager1'
DBUS_OM_IFACE = 'org.freedesktop.DBus.ObjectManager'
DBUS_PROP_IFACE = 'org.freedesktop.DBus.Properties'
...
def main(timeout=0):
...
adapter_props = dbus.Interface(bus.get_object(BLUEZ_SERVICE_NAME, adapter),
"org.freedesktop.DBus.Properties")
adapter_props.Set("org.bluez.Adapter1", "Powered", dbus.Boolean(1))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.