hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
185 stars 73 forks source link

Reading Properties #138

Closed Gianmariai closed 3 years ago

Gianmariai commented 3 years ago

Hello, sorry, it's not clear to me how can i read Properties using dbus-java and how to subscribe for their value changed.. for example I'm working on ModemMAnager, that exposes a lot of properties here: https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/gdbus-org.freedesktop.ModemManager1.Modem.html But I cant understand how to read it.

Sorry for question. Thanks Gianmaria Italy

hypfvieh commented 3 years ago

Sample for reading properties Sample for properties changed listener

Gianmariai commented 3 years ago

THANK you so much David.

Gianmaria

Gianmariai commented 3 years ago

I'm still doing something wrong...

    DBusConnection connection = DBusConnection.getConnection(DBusConnection.DBusBusType.SYSTEM);
    org.freedesktop.dbus.interfaces.Properties properties = connection.getRemoteObject("org.freedesktop.ModemManager1", "/org/freedesktop/ModemManager1/Modem/Modem3gpp", org.freedesktop.dbus.interfaces.Properties.class);
    IMEI = properties.Get("org.freedesktop.ModemManager1.Modem.Modem3gpp", "Imei");
    connection.disconnect();

gives me error at runtime: No such interface “org.freedesktop.DBus.Properties” on object at path /org/freedesktop/ModemManager1/Modem/Modem3gpp

I'm still missing something..

gianmaria

hypfvieh commented 3 years ago

I don't know what you are trying to do. Please use d-feet or similar to investigate the exported DBus objects and to find to correct object path and busname. On my machine I have a /org/freedesktop/ModemManager1 object path and a org.freedesktop.ModemManager1 object on the bus. I don't see any /org/freedesktop/ModemManager1/Modem/Modem3gpp path using d-feet.

Gianmariai commented 3 years ago

unfortunatly I dont have d-feet on target machine, it's a small embedded device without display and any X interface. Will update this thread with solution once i finish to investigate, maybe it can be useful to someonee else.

Regards David. Gianmaria