mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-10 05:51:40 +00:00
Add debugging for network scan (#1559)
* Add debugging for network scan * Fix eslint warning
This commit is contained in:
+6
-1
@@ -305,6 +305,7 @@ class Zigbee {
|
||||
};
|
||||
|
||||
const processResponse = function(parent, shepherd) {
|
||||
logger.debug(`Scanning device: '${parent}'`);
|
||||
return function(data) {
|
||||
const linkSet = [];
|
||||
return new Promise((resolve) => {
|
||||
@@ -315,21 +316,25 @@ class Zigbee {
|
||||
linkSet.push(devinfo);
|
||||
});
|
||||
resolve(linkSet);
|
||||
logger.debug(`Processed device: '${parent}', linkSet: %j`, linkSet);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
const allScans = this.getScanable().map((dev) => {
|
||||
logger.debug(`Preparing asynch network scan for '${dev.ieeeAddr}'`);
|
||||
return this.shepherd.lqi(dev.ieeeAddr).then(processResponse(dev.ieeeAddr, this.shepherd));
|
||||
}, this);
|
||||
logger.debug('All network map promises created');
|
||||
// Collect all lqi scans but timeout after 2 seconds if any fail
|
||||
Promise.raceAll(allScans, 2000, []).then((linkSets) => {
|
||||
const linkMap = [].concat(...linkSets);
|
||||
logger.info('Network scan completed');
|
||||
logger.debug(`Link map: %j`, linkMap);
|
||||
callback(linkMap);
|
||||
})
|
||||
.catch(function(result) {
|
||||
logger.info('Network scan failed');
|
||||
logger.info(`Network scan failed: '${result}'`);
|
||||
callback([]);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user