sidorares / dbus-native

D-bus protocol client and server for node.js written in native javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Listen to Methods called on bus

ZwiebelTVDE opened this issue · comments

I can't seem to figure out how to listen to methods called on the bus.
I can see the needed frames using the command: dbus-monitor --system member=notifyDriverState in the Linux terminal but my code is not working.

The command output looks like this:

method call sender=:1.1 -> dest=foo.bar.ConnectivityController serial=14951 path=/ConnectivityController; interface=foo.bar.DBusConnectivityController; member=notifyDriverState
   string "some string"
   uint32 2 

My code boils down to this:

const dbus = require('dbus-native');
const systemBus = dbus.systemBus();
const connectivityService = systemBus.getService('foo.bar.ConnectivityController');
connectivityService.getInterface('/ConnectivityController', 'foo.bar.DBusConnectivityController', (err, iface)=>{
	if(err|| !iface){
		console.error(
			'Could not query interface foo.bar.DBusConnectivityController, the error was: ${err}'
				? err
				: '(no error)'
		);
		process.exit(1);
	}
	iface.on('notifyDriverState', (somestring, somenumber)=>{
		console.log('Some string: ' + somestring);
		console.log('Some Number: ' + somenumber);
	})
});

I never see the console outputs so I assume the code is somewhat faulty.

Am I doint something wrong or is the problem somewhere in the documentation for this project?