Skip to content
  • 0 Votes
    2 Posts
    85 Views
    jsulmJ

    @AROH I guess you need to declare/register QVector<int>, see https://doc.qt.io/qt-6/custom-types.html

  • QDBus path encoding

    Unsolved General and Desktop
    4
    0 Votes
    4 Posts
    374 Views
    C

    Thank you for the answer. Honestly I expected this as some kind of magic done in background...
    At the moment I will use the sd_bus_path_encode function.
    The source of the function can be found at https://github.com/systemd/systemd/blob/main/src/basic/bus-label.c called bus_label_escape.

  • 0 Votes
    2 Posts
    590 Views
    F

    You have to register the expected Response first!

    In my case it was like

    #include <QtDBus/QDBusMetaType> // ... typedef QMap<QString, QMap<QString, QVariant> > ConnectionDetails; Q_DECLARE_METATYPE(ConnectionDetails)

    and

    int main() { qDBusRegisterMetaType<ConnectionDetails>(); // ... }
  • 0 Votes
    1 Posts
    328 Views
    No one has replied
  • 0 Votes
    3 Posts
    821 Views
    C

    @SGaist You're right,I did not think about it! I have to remove the systemBus, I'm not using it in reality, it's part of the project that I found on Github. Ok then I can try to make it an instance variable of the class or similer. Thank you!

  • 0 Votes
    2 Posts
    1k Views
    M

    @Mark81 ok, I found a way:

    QDBusInterface *iface = new QDBusInterface("your.service", "/your/path", "org.freedesktop.DBus.Introspectable", QDBusConnection::systemBus(), this); qDebug() << iface->call("Introspect").arguments();
  • 0 Votes
    2 Posts
    1k Views
    kshegunovK

    @Mark81
    Hi,

    I'm not sure if it is returned from some DBus methods or I have to manually build it using the bluetooth address and the local device.

    It is not, you have to handle it manually. From what I can discern from your link it's a path you construct out of device names. If the service is compliant you can usually list the objects it exposes.

    Kind regards.

  • 0 Votes
    1 Posts
    2k Views
    No one has replied
  • 0 Votes
    1 Posts
    846 Views
    No one has replied
  • 0 Votes
    2 Posts
    2k Views
    SGaistS

    Hi and welcome to devnet,

    Since it might need some knowledge of the internals of QtDBus, I'd recommend posting this question on the interest mailing list You'll find there Qt's developers/maintainers (this forum is more user oriented)

  • 0 Votes
    1 Posts
    825 Views
    No one has replied
  • 1 Votes
    2 Posts
    6k Views
    S

    I got it working. Problem was that instead of bool I had to use QVariant of QDBusVariant type. So the two functions look like this now:

    These are the defines I've used:

    #define BLUEZ_DBUS_SERVICE "org.bluez" #define BLUEZ_DBUS_PATH "/org/bluez/hci0" #define BLUEZ_DBUS_IF "org.bluez.Adapter1"

    And here is the first implementationÖ

    QDBusConnection bus = QDBusConnection::systemBus(); if (!bus.isConnected()) { qFatal("Cannot connect to the D-Bus session bus."); return; } QDBusMessage message = QDBusMessage::createMethodCall(BLUEZ_DBUS_SERVICE, BLUEZ_DBUS_PATH, "org.freedesktop.DBus.Properties", "Set"); QList<QVariant> arguments; arguments << BLUEZ_DBUS_IF << "Powered" << QVariant::fromValue(QDBusVariant(true)); message.setArguments(arguments); QDBusPendingReply<QVariantMap> reply = bus.asyncCall(message); reply.waitForFinished();

    and here is the second possibility to implement the method call:

    QDBusConnection bus = QDBusConnection::systemBus(); if (!bus.isConnected()) { qFatal("Cannot connect to the D-Bus session bus."); return; } QDBusInterface dbus_iface(BLUEZ_DBUS_SERVICE, BLUEZ_DBUS_PATH, "org.freedesktop.DBus.Properties", bus); if ( dbus_iface.isValid() ) { QDBusPendingReply<QVariantMap> reply = dbus_iface.asyncCall("Set", BLUEZ_DBUS_IF, "Powered", QVariant::fromValue(QDBusVariant(true))); reply.waitForFinished(); reply.error().message(); }

    In case anybody wants to do the same thing there is also the possibility to set the "Powered" property directly:

    QDBusInterface ifc( BLUEZ_DBUS_SERVICE, BLUEZ_DBUS_PATH, BLUEZ_DBUS_IF, QDBusConnection::systemBus()); if ( ifc.isValid() ) { ifc.setProperty("Powered", true); }