什么时候调用DBusWatch callbak?

时间:2019-07-17 02:05:16

标签: bluetooth glib dbus bluez gdbus

我正在阅读bluez中包含的bluetoothctl源代码,并希望使用gdbus自己控制ble。当我读到这篇文章:

dbus_connection_set_watch_functions(conn, add_watch, remove_watch,
                        watch_toggled, conn, NULL);

dbus_connection_set_timeout_functions(conn, add_timeout, remove_timeout,
                        timeout_toggled, NULL, NULL);

dbus_connection_set_dispatch_status_function(conn, dispatch_status,
                                NULL, NULL);

我的问题是这些回调(add_watchremove_watchwatch_toggledadd_timeoutremove_timeouttimeout_toggled,{{1} })将被调用?

我已经进行了一些验证:我在这些功能中添加了一些打印日志,然后键入dispatch_status命令并仅按Enter键,我发现bluetoothctladd_watch已被多个调用次。在DBus文档中有以下信息:

remove_watch

据我了解,此连接没有更改,为什么dbus_connection_set_watch_functions(): Sets the watch functions for the connection. These functions are responsible for making the application's main loop aware of file descriptors that need to be monitored for events, add_watch被调用了几次?那么,这个“监视”功能监视的确切对象是什么(也是“超时”)?在什么条件下将调用这些函数?有人为此提供一些很好的示例代码吗?谢谢吗?

0 个答案:

没有答案