I'm trying to call D-Bus method, but don't understand how to add needed args.
- Method name: CreateSession (String destination, Dict of {String, Variant} args) ↦ (Object Path session)
- Bus Name: org.bluez.obex
- Object Path: /org/bluez/obex
- Interface: org.bluez.obex.Client1
I successfully can call this method in D-Feet app with this arguments:
"D0:9C:7A:A1:A4:63",{'Target':GLib.Variant('s','OPP')}
But how make the same using only dbus.h?
Here's my code:
// Do before compile sudo apt-get install -y libdbus-1-dev
// gcc -o test -Wall test.c `pkg-config --cflags dbus-1` `pkg-config --libs dbus-1`
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dbus/dbus.h>
int main() {
DBusConnection *sesBusCon;
DBusError error;
DBusMessage *call;
DBusMessage *reply;
dbus_error_init(&error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
sesBusCon = dbus_bus_get(DBUS_BUS_SESSION, &error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
call = dbus_message_new_method_call("org.bluez.obex", "/org/bluez/obex", "org.bluez.obex.Client1", "CreateSession");
reply = dbus_connection_send_with_reply_and_block (sesBusCon, call, 100000, &error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
return 0;
}