dbus - 如何查找在 D-Bus 接口(interface)中公开的方法

标签 dbus bluez

问题:有什么方法可以找出 D-Bus 接口(interface)中公开的方法(及其签名)?

问题描述:在我的手机中,我正在使用 D-Bus 到适配器接口(interface)调用 BlueZ 方法,当在手机 2 上检查时,这些方法中的一个不可用。

目的是检查方法名称/签名是否在其他设备中被修改,我无权访问代码,因此希望在接口(interface)中找到方法

最佳答案

使用 dbus-send,您可以列出系统上的可用服务:

session :

dbus-send --session           \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply               \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames

系统:
dbus-send --system            \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply               \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames

你会得到这样的答案:
   array [
      string "org.freedesktop.DBus"
      string ":1.1"
      string ":1.26"
      string "org.asamk.Signal"
   ]

如果你想列出 dbus 服务背后的所有可用方法,你仍然可以使用 dbus-send 来内省(introspection) dbus 服务。

例如 org.asamk.Signal :
  dbus-send --system --type=method_call --print-reply \
      --dest=org.asamk.Signal \
      /org/asamk/Signal \
      org.freedesktop.DBus.Introspectable.Introspect

你会得到这种结果(截断)
<node name="/org/asamk/Signal">
 <interface name="org.asamk.Signal">
  <method name="sendMessage" >
   ...parameters
  </method>                      
  <method name="sendGroupMessage" >     
   ...parameters
  </method>
 </interface>
</node>

这里有2个方法,sendMessagesendGroupMessage

关于dbus - 如何查找在 D-Bus 接口(interface)中公开的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19955729/

相关文章:

c - 共享库插件和从主程序调用函数 (Bluez)

linux - 如何从命令行发出 dbus 信号

python - pyBluez python 服务器 - 手机看不到我的服务器

bluetooth - 最大数量使用 BlueZ 的 BLE 连接

Python DBUS - 带有额外参数的接口(interface)上的 `PropertiesChanged` 监听器

embedded-linux - BlueZ:没有可用的默认 Controller

linux - 低功耗蓝牙 : listening for notifications/indications in linux

qt - 从 ObServer 发出的选择性 D-BUS 信号(单播信号)

Redis messagebus 与 d-bus : what is happening at a low level? 基本上是同一件事?

linux - 当用户按下可编辑的 UI 组件时在 Linux 中自动启动键盘