Here I want to know about dbus-send command in brief
I want to know how we can use this and how this command call automatically functions of other c files.
Here I put one example which is used in Bluetooth pairing and unpairing. please Explain me
dbus-send --system --print-reply --dest=org.bluez $BT_ADAPTER org.bluez.Adapter.RemoveDevice objpath:$BT_ADAPTER/dev_$BD_ADDR_XX
Here BT_ADAPTER is Blue adapter like: /org/bluez/1536/hci0
BD_ADDR_XX is Bluetooth address: XX_XX_XX_XX_XX_XX
Here I know about –system –print-reply options and all others options but how its works with source files I do not know.
So Anybody please can Explain me hows this command call and use functions from C source files.
You need to check out dbus document and there’s a long way to go.
http://www.freedesktop.org/wiki/IntroductionToDBus
What exactly do you want? Writing a dbus service or a client?
Must you write in C, because python would be a far better choice.
http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html
============================
First, a dbus service connects to dbus-daemon and ask for a service address(in your case org.bluez).
Then it registers different interface at different object paths, each interface contains some method calls/signals for users to use.
In your case:
Dbus daemon process(dbus-daemon –system) is started.
Bluez daemon process started and ask dbus-daemon for “org.bluez” service address
Bluez daemon process register some interfaces at /org/bluez/{process pid}/{bluetooth controller name} (check bluez source code, in doc directory)
When you call dbus-send command, the command line tool will connect to dbus-daemon, sending the service address(-dest), object path(/org/bluez/1536/hci0), interface name, the method you call(
org.bluez.Adapter.RemoveDevice) and parameters.
Dbus-daemon resend it to bluez
============================
Dbus daemon doesn’t get service address or method calls.
It’s you or client process who tells it the service address and method-call names.
DBus daemon will then send target service process a data packet contains obj-path, interface/method name and parameters in its own format(through a unix local socket file).
Target service process then unpacks the packet, get the object-path, interface and etc. , decide what it should do. That’s not automatically done and you need to write your own code to handle it(method dispatch or so), or use some library like dbus-glib/gdbus.
============================
I checked source code of Bluez-4.98. It uses gdbus for method dispatch.
Take “CreateDevice” for example.
in src/adapter.c, there’s such a struct
which means CreateDevice Method call will eventually calls create_device function.
And in line 2418
you register the interface ADAPTER_INTERFACE(“org.bluez.Adapter”) with all its methods and signals.
Then all the underlying dbus event monitor and method dispatch will be handled by gdbus(after init dbus connection and event handling in src/main.c). When some client calls org.bluez.Adapter.CreateDevice, it eventually get into function create_device at src/adapter.c line 1468.
I’m not familiar with gdbus and if you want to dig deeper I suggest you to check the official website: http://developer.gnome.org/gio/stable/gdbus-convenience.html
============================
lol
Then you just need to check out ‘test’ directory of bluez source code.
There are both python and C examples.
Also, bluez dbus interface changed a lot from 3.XX to 4.XX, so check out the right version.