Commit 6a361c40 authored by Donald Chen's avatar Donald Chen
Browse files

cleanup

parent 8a5622f1
......@@ -15,6 +15,7 @@ class Device {
this.fwVersion = null;
this.timer = null;
}
/**
* Returns a Promise that will resolve with the ble device's firmware revision,
* or reject with an error
......@@ -44,7 +45,6 @@ class Device {
return new Promise((resolve, reject) => {
this.timer = setTimeout(() => {
console.log(`connection timeout: ${this.id}`)
this.bleDevice.disconnect();
reject("connection timeout")
}, 10000)
......@@ -55,9 +55,8 @@ class Device {
}
if(this.timer == null) {
console.log(`duplicate connection timeout: ${this.id}`)
this.bleDevice.disconnect();
reject("connection already timed out")
reject("connection timeout")
} else {
clearTimeout(this.timer)
this.timer = null
......
......@@ -74,7 +74,7 @@ function onDiscover(beaconInst) {
devices[device.id] = device;
// Set disconnect handler
device.bleDevice.once('disconnect', function disconnectHandler() {
device.bleDevice.on('disconnect', function disconnectHandler() {
console.log(`${device.id}: disconnected`);
device.bleDevice.removeListener('disconnect', disconnectHandler);
device.resetState();
......@@ -98,4 +98,4 @@ noble.on('scanStart', () => {
console.log('Scanning started');
});
rigadoSensorBeacon.discoverAll(onDiscover);
\ No newline at end of file
rigadoSensorBeacon.discoverAll(onDiscover);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment