Try to recover in zigbee-shepherd start failure. #79

This commit is contained in:
Koenkk
2018-06-01 21:04:48 +02:00
parent 811cf2943f
commit f0b19cc696
+16 -3
View File
@@ -28,12 +28,25 @@ class Zigbee {
this.shepherd.start((error) => {
if (error) {
logger.error('Error while starting zigbee-shepherd!');
logger.warn('Error while starting zigbee-shepherd, attemping to fix...');
this.shepherd.controller._znp.close((() => null));
logger.info(`Starting zigbee-shepherd`);
setTimeout(() => {
this.shepherd.start((error) => {
if (error) {
logger.error('Error while starting zigbee-shepherd!');
callback(error);
} else {
logger.info('zigbee-shepherd started');
callback(null);
}
});
}, 5 * 1000);
} else {
logger.info('zigbee-shepherd started');
callback(null);
}
callback(error);
});
// Register callbacks.