Developing and extending Agent1
From: Mihai Emilian <hidden>
Date: 2021-03-18 18:05:30
Dear community,
I am attempting to create a service that extends the functionality of
Bluez Pairing. I want to rewrite some of the functionality for
different paring methods (capabilities).
I read [this blog which uses Qt][1] to generate the code to create the
base code for the agent.
I used `gdbus-codegen` to generate the C code (like this[2]), using
the XML given in the blog in [1].
Then, in my main function, I acquired a SYSTEM BUS name and exported
all objects, including an object manager. My setup now looks like
this:[3]
Finally, I created a `callback` function based on the GDBUS signal
based on `handle-request-confirmation` which looks like this:
g_signal_connect(agent, "handle-request-confirmation",
G_CALLBACK (on_request_confirmation), NULL);The above code is in main()
int on_request_confirmation(CustomOrgBluezAgent1 *agent,
GDBusMethodInvocation *invocation, gchar* path,
guint32 passkey, gpointer userdata) {
g_print("Hello WORLD!");
set_trusted(path);
return TRUE;
}This is the actual callback function
My problem is that I am not able to have my Agent1 interface register as a default agent. I tried invoking the `AgentManager1` in `org.bluez` with `RegisterAgent` and `RequestDefaultAgent`, but it doesn't seem to use the newly created service and I assume it uses a separate one within the `org.bluez` service. I have a couple of questions: - Is this the proper way to implement a custom Agent1? - How do I make it the default agent? - How can I check what Agent is currently the default? It doesn't appear anywhere in `d-feet` (the GUI d-bus explorer). I noticed the agent implemented in Ubuntu though obex, but this is in Session (when the bluetooth settings app is opened, the service appears in the Session Bus):[4] [1]: https://medium.com/@matteodipirro/developing-a-bluetooth-agent-in-qt-c-with-bluez-and-d-bus-part-1-ee35d614ba72 [2]: https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/gio/ch30s05.html [3]: https://i.stack.imgur.com/pe0Li.png [4]: https://i.stack.imgur.com/UQ8na.png Many thanks and regards, Mihai