Skip to content

Commit 5ab00a6

Browse files
authored
Fix closing of not connected devices (#25)
On close, only close the device if there is one and clear the reconnect timeout.
1 parent 5274ad7 commit 5ab00a6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/busylight.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ Busylight.prototype.defaults = function(options){
131131
};
132132

133133
Busylight.prototype.close = function(){
134-
this.device.close();
134+
if (this.device) {
135+
this.device.close();
136+
}
137+
if (this.reconnectTimer) {
138+
clearTimeout(this.reconnectTimer);
139+
this.reconnectTimer = null;
140+
}
135141
};
136142

137143
Busylight.prototype.off = function(){

0 commit comments

Comments
 (0)