Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get property #293

Open
roddc opened this issue Mar 29, 2023 · 2 comments
Open

How to get property #293

roddc opened this issue Mar 29, 2023 · 2 comments

Comments

@roddc
Copy link

roddc commented Mar 29, 2023

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.

@sidorares
Copy link
Owner

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 ?

@sidorares
Copy link
Owner

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants