Dubs Connman wifi connect Qt

721 views Asked by At

I'am working on an imx6, and i'am trying to connect to a wifi network through Dbus with a Qt application. The application connect correctly to connman via Dbus and i recieve correctly the wifi services. The problem is that when i try to connect to a wiif network i catch this error :

"Method "Connect" with signature "ss" on interface "net.connman.Service" doesn't exist

The code that i'am using in Qt application to coonect to a wifi network is:

QDBusInterface *iface =
new QDBusInterface("net.connman","/net/connman/technology/wifi","net.connman.Service",QDBusConnection::systemBus());

if (!iface->isValid())
{
    qDebug() << Q_FUNC_INFO << "Fail to connect to the Connman Technology interface: " << QDBusConnection::systemBus().lastError().message();
}



QDBusReply<void> reply = iface->call("Connect","/net/connman/service/wifi_88da1a4db14c_41684179_managed_psk","password");

if (!reply.isValid())
{
    qDebug() << "Call connect result: " << reply.error().message();
}

When i try to connect to the wifi network with shell commands using connmanctl it works like a charm.

2

There are 2 answers

0
Jakub Warchoł On BEST ANSWER

I had the same problem on imx6. The solution which works for me is creating a configuration file for network before invoking Connect method.

The file should be in /var/lib/connman and name [SSID].config . File content:

[service_wifi_PUT_SERVICE_NAME]
Name = PUT_SSID
Type = wifi
Passphrase = PUT_PASSWORD

And try connecting in this way:

QDBusInterface *iface =  new QDBusInterface("net.connman", QString{"/net/connman/service/%1"}.arg(SERVICE_NAME), "net.connman.Service", QDBusConnection::systemBus());
QDBusReply<void> reply = iface->call("Connect");
if(!reply.isValid() {
...
0
Robert McLean On

The Qt app I'm working on at the moment requires an interface to connman, and I found this library to be helpful libconnman-qt.

Understanding how the agent works was also bit tricky, but looking at the connman api documents directly was also helpful connman documentation. It helped to start with the "overview-api.txt".