dbus-native
dbus-native copied to clipboard
Callback never received
I was trying to figure out why a certain part of my code seemingly never executed but it seems that a callback from the node-dbus API is never called.
The code in question: (bus.js : 289)
this.getInterface = function(path, objname, name, callback) {
return this.getObject(path, objname, function(err, obj) {
if (err) return callback(err);
callback(null, obj.as(name));
});
};
I have tried debugging the node-dbus library use the node dbug command but have been unable to find the cause. (the execution seemingly steps over the callback and never executes.)
For reference my code:
function getWPA_Supplicant() {
return new Promise(function(resolve, reject) {
wpai = wpas.getInterface('/fi/w1/wpa_supplicant1'
, 'fi.w1.wpa_supplicant1', function (err, iface) {
//console.log(err, iface);
if (err) {
return reject(new Error(err));
}
iface.on('PropertiesChanged', function(dict) {
console.log('interface properties have changed!');
console.log(dict + "\n");
});
iface.on('InterfaceAdded', function(path, dict) {
console.log('interface has been added!'+ "\n");
});
iface.on('InterfaceRemoved', function(path) {
console.log('interface has been removed!');
console.log(path + "\n");
});
//fulfill the promise by returning the wireless interface
return resolve(iface);
});
});
}
//We promise to get the wireless interface that already exists
function getWirelessInterface(){
return new Promise(function(resolve, reject) {
console.log("entering promise");
console.log(wpas);
debugger;
wlif = wpas.getInterface('fi/wi/wpa_supplicant1/Interfaces/1'
, 'fi.w1.wpa_supplicant1.Interface', "testingInterface", function (err, iface2) {
console.log(err, iface2);
//TODO this never resolves
debugger;
if (err) {
console.log("rejected error!");
return reject(new Error(err));
}
console.log("after err step");
iface2.on('ScanDone', function (result) {
console.log("Scan is Done..");
console.log(result);
});
iface2.on('NetworkAdded', function (path, properties) {
console.log("NetworkAdded");
console.log(path, properties);
});
iface2.on('NetworkRemoved', function (path) {
console.log("NetworkRemoved");
console.log(path);
});
iface2.on('PropertiesChanged', function (properties) {
console.log("PropertiesChanged");
console.log(properties);
});
console.log("we enter the resolve step");
return resolve(iface2);
});
});
}
function setup(){
if (fs.existsSync('/run/wpa_supplicant/wlan0')) {
//clean the run directory of any old interface instances
fs.unlinkSync('/run/wpa_supplicant/wlan0', (err) => {
if (err) {
throw new Error(err);
}
console.log("deleted /run/wpa_supplicant/wlan0");
});
}
getWPA_Supplicant().then(function(iface) {
console.log("returning connect");
return connect(iface);
}).then(function() {
console.log("returning getwirelessInterface");
var value = getWirelessInterface();
console.log(value);
return value;
}).then(function () {
debugger;
console.log("after the getInterface");
}).catch(console.error.bind(console));
function connect(iface2) {
console.log("connect");
return new Promise (function(resolve, reject) {
var retface = iface2.CreateInterface([
['Ifname',
['s', 'wlan0']
],
['Driver',
['s', 'nl80211']
],
['ConfigFile',
['s', '/etc/wpa_supplicant/wpa_supplicant.conf']
]
], function (err, iface3){
console.log(err, iface3);
if (err) {
return reject(new Error(err));
}
return resolve(retface);
});
});
}
This happens to me too. The Introspect
request never get completed
might be related: #117