Skip to content

Commit ae086d5

Browse files
authored
Added attempt reconnect method
Added attempt reconnect method for godice class
1 parent 25b2a4a commit ae086d5

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

godice.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,20 @@ class GoDice {
280280
this.connectDeviceAndCacheCharacteristics();
281281
});
282282
}
283+
284+
/**
285+
* Attempts to reconnect to the device incase of disconnect
286+
*/
287+
attemptReconnect() {
288+
if (this.bluetoothDevice) {
289+
// This object's device exists
290+
if (this.bluetoothDevice.gatt.connected) {
291+
console.debug(this.GlobalDeviceId + "'s Bluetooth device is already connected")
292+
} else {
293+
this.connectDeviceAndCacheCharacteristics()
294+
}
295+
}
296+
}
283297

284298
/**
285299
* Turn On/Off RGB LEDs, will turn off if led1 and led2 are null

0 commit comments

Comments
 (0)