Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Fix for #160 and better serial error handling #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions nodes/shepherd.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,18 +619,21 @@ module.exports = function (RED) {
this.proxy.emit('ready');
this.status = 'connected';
this.proxy.emit('nodeStatus', {fill: 'green', shape: 'dot', text: 'connected'});
this.herdsman.supportsLED().then(supportsLED => {
if (supportsLED === true) {
this.herdsman.setLED(this.led === 'enabled').then(() => {
this.debug(`setLED successfully set ${this.led}`);
}).catch(error => {
this.error(`setLED failed to set ${this.led} ${error.message}`);
});
} else if (this.led === 'enabled') {
this.error('Setting LED not supported on this adapter. To avoid this message at startup, set CC2531 LED to \'disabled\' in controller node');
}
});


if (this.herdsman.supportsLED !== undefined)
{
this.herdsman.supportsLED().then(supportsLED => {
if (supportsLED === true) {
this.herdsman.setLED(this.led === 'enabled').then(() => {
this.debug(`setLED successfully set ${this.led}`);
}).catch(error => {
this.error(`setLED failed to set ${this.led} ${error.message}`);
});
} else if (this.led === 'enabled') {
this.error('Setting LED not supported on this adapter. To avoid this message at startup, set CC2531 LED to \'disabled\' in controller node');
}
});
}
this.checkOverdueInterval = setInterval(() => {
this.checkOverdue();
}, 60 * 1000);
Expand All @@ -653,9 +656,12 @@ module.exports = function (RED) {
this.status = error.message;
this.proxy.emit('nodeStatus', {fill: 'red', shape: 'ring', text: error.message + ', retrying'});
this.error(error.message);
setTimeout(() => {
this.connect();
}, 10000);

this.herdsman.stop().finally().then( () => {
setTimeout(() => {
this.connect();
}, 10000);
});
}).finally(() => {
this.connecting = false;
});
Expand Down