【问题标题】:Dubs Connman wifi connect QtDubs Connman wifi 连接 Qt
【发布时间】:2020-09-07 10:41:31
【问题描述】:

我正在开发一个 imx6,我正在尝试使用 Qt 应用程序通过 Dbus 连接到 wifi 网络。 该应用程序通过 Dbus 正确连接到 connman,并且我正确接收了 wifi 服务。 问题是当我尝试连接到 wiif 网络时,我发现了这个错误:

“接口“net.connman.Service”上带有签名“ss”的方法“Connect”不存在

我在 Qt 应用程序中用于连接到 wifi 网络的代码是:

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();
}

当我尝试使用 connmanctl 使用 shell 命令连接到 wifi 网络时,它就像一个魅力。

【问题讨论】:

    标签: qt wifi dbus connman


    【解决方案1】:

    我在 imx6 上遇到了同样的问题。对我有用的解决方案是在调用 Connect 方法之前为网络创建一个配置文件。

    该文件应位于 /var/lib/connman 中,名称为 [SSID].config 。 文件内容:

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

    并尝试以这种方式连接:

    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() {
    ...
    

    【讨论】:

      猜你喜欢
      • 2022-12-21
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      相关资源
      最近更新 更多