sidorares/dbus-native

How to get property

roddc opened this issue · 2 comments

roddc commented
const sysBus = dbus.systemBus();

const SERVICE_NAME = "org.freedesktop.NetworkManager";
const NM_OBJECT_PATH = "/org/freedesktop/NetworkManager";
const DEVICE_IFACE = "org.freedesktop.NetworkManager";

sysBus
  .getService(SERVICE_NAME)
  .getInterface(NM_OBJECT_PATH, DEVICE_IFACE, (err, nm) => {
    console.log(err, nm);
    //  This does not work, nm.Devices is not a function
   //  nm.Devices((e,v) => { console.log(e,v)});

   // This works
    nm.$readProp("Devices", (e, v) => {
      console.log(e, v);
    });
  });

How do I call the getter as a function?
I am using Node 16.19.

I haven't used dbus-native in a long time but what you do looks correct

All properties are added to the interface like this:

get: () => callback => this.$readProp(propName, callback),

What is the content of nm.$properties ?

Try do add a breakpoint here

currentIface.$createProp(property['$'].name, property['$'].type, property['$'].access)
and step over and see what's actually going on

Can you also post interface xml definition you are getting so I can create some test scripts without actually connecting to dbus-daemon ?