I am planning to develop an application that will make use of DBus and connman, a wireless manager for embedded devices. From my understanding DBus exposes the methods used by a program, and allows developers to also make use of these methods in their own program.
I know Qt has the QtDbus module, and if my understanding is correct, the GetServices method under the net.connman.Manager interface shows the wireless networks available. Inspecting the output of the GetServices method from the qdbusviewer program, I can see that each wireless network has its own unique object path, an example would be /net/connman/service/wifi_00120ec15ba0_4c616964614d616774616c6173_managed_psk.
To use the Connect and Disconnect method under the net.connman.Services interface, I need the object path so that I can create a new interface that would allow me to call Connect/Disconnect. I am currently trying the methods outlined here How do I extract the returned data from QDBusMessage in a Qt DBus call?, but I only get a blank when I try to return the object path:
Here is my code to obtain the object path:
QDBusConnection bus = QDBusConnection::systemBus();
QDBusInterface *interface = new QDBusInterface("net.connman",
"/",
"net.connman.Manager",
bus,
this);
QDBusMessage test = interface->call("GetServices");
QList<QVariant> outArgs = test.arguments();
QVariant first = outArgs.at(0);
qDebug() << first;
QDBusVariant dbvFirst = first.value<QDBusVariant>();
QVariant vFirst = dbvFirst.variant();
qDebug() << vFirst;
QDBusArgument dbusArgs = vFirst.value<QDBusArgument>();
qDebug() << "QDBusArgument current type is" << dbusArgs.currentType();
QDBusObjectPath path;
dbusArgs.beginArray();
while (!dbusArgs.atEnd())
{
dbusArgs >> path;
}
dbusArgs.endArray();
qDebug() << path.path();
How do I extract the arguments and the object path returned by the GetService method? Has anyone done this correctly? I am new to Qt and programming, so any help would be appreciated.
Thanks