diff --git a/src/boostmovehub.ts b/src/boostmovehub.ts index c296e35..9e924a3 100644 --- a/src/boostmovehub.ts +++ b/src/boostmovehub.ts @@ -34,8 +34,8 @@ export class BoostMoveHub extends LPF2Hub { } - constructor (peripheral: BLEDevice, autoSubscribe: boolean = true) { - super(peripheral, autoSubscribe); + constructor (device: BLEDevice, autoSubscribe: boolean = true) { + super(device, autoSubscribe); this.type = Consts.HubType.BOOST_MOVE_HUB; this._ports = { "A": new Port("A", 55), diff --git a/src/duplotrainbase.ts b/src/duplotrainbase.ts index c5c6dca..9abcc5b 100644 --- a/src/duplotrainbase.ts +++ b/src/duplotrainbase.ts @@ -64,8 +64,8 @@ export class DuploTrainBase extends LPF2Hub { } - constructor (peripheral: BLEDevice, autoSubscribe: boolean = true) { - super(peripheral, autoSubscribe); + constructor (device: BLEDevice, autoSubscribe: boolean = true) { + super(device, autoSubscribe); this.type = Consts.HubType.DUPLO_TRAIN_HUB; this._ports = { "MOTOR": new Port("MOTOR", 0), diff --git a/src/hub.ts b/src/hub.ts index 738af11..63b26de 100644 --- a/src/hub.ts +++ b/src/hub.ts @@ -119,70 +119,14 @@ export class Hub extends EventEmitter { */ public connect () { return new Promise(async (connectResolve, connectReject) => { - - const self = this; - if (this._isConnecting) { return connectReject("Already connecting"); } else if (this._isConnected) { return connectReject("Already connected"); } - this._isConnecting = true; await this._bleDevice.connect(); return connectResolve(); - // this._peripheral.connect((err: string) => { - - // this._rssi = this._peripheral.rssi; - // const rssiUpdateInterval = setInterval(() => { - // this._peripheral.updateRssi((err: string, rssi: number) => { - // if (!err) { - // if (this._rssi !== rssi) { - // this._rssi = rssi; - // } - // } - // }); - // }, 2000); - - // self._peripheral.on("disconnect", () => { - // clearInterval(rssiUpdateInterval); - // this._isConnecting = false; - // this._isConnected = false; - // this.emit("disconnect"); - // }); - - // self._peripheral.discoverServices([], (err: string, services: Service[]) => { - - // if (err) { - // this.emit("error", err); - // return; - // } - - // debug("Service/characteristic discovery started"); - // const servicePromises: Array> = []; - // services.forEach((service) => { - // servicePromises.push(new Promise((resolve, reject) => { - // service.discoverCharacteristics([], (err, characteristics) => { - // characteristics.forEach((characteristic) => { - // this._characteristics[characteristic.uuid] = characteristic; - // }); - // return resolve(); - // }); - // })); - // }); - - // Promise.all(servicePromises).then(() => { - // debug("Service/characteristic discovery finished"); - // this._isConnecting = false; - // this._isConnected = true; - // this.emit("connect"); - // return connectResolve(); - // }); - - // }); - - // }); - }); } diff --git a/src/puphub.ts b/src/puphub.ts index 7bc2416..5b7d34d 100644 --- a/src/puphub.ts +++ b/src/puphub.ts @@ -39,8 +39,8 @@ export class PUPHub extends LPF2Hub { } - constructor (peripheral: BLEDevice, autoSubscribe: boolean = true) { - super(peripheral, autoSubscribe); + constructor (device: BLEDevice, autoSubscribe: boolean = true) { + super(device, autoSubscribe); this.type = Consts.HubType.POWERED_UP_HUB; this._ports = { "A": new Port("A", 0), diff --git a/src/pupremote.ts b/src/pupremote.ts index ba33ed0..bf64c7e 100644 --- a/src/pupremote.ts +++ b/src/pupremote.ts @@ -64,8 +64,8 @@ export class PUPRemote extends LPF2Hub { } - constructor (peripheral: BLEDevice, autoSubscribe: boolean = true) { - super(peripheral, autoSubscribe); + constructor (device: BLEDevice, autoSubscribe: boolean = true) { + super(device, autoSubscribe); this.type = Consts.HubType.POWERED_UP_REMOTE; this._ports = { "LEFT": new Port("LEFT", 0), diff --git a/src/wedo2smarthub.ts b/src/wedo2smarthub.ts index b405c24..7497005 100644 --- a/src/wedo2smarthub.ts +++ b/src/wedo2smarthub.ts @@ -37,8 +37,8 @@ export class WeDo2SmartHub extends Hub { private _lastTiltY: number = 0; - constructor (peripheral: BLEDevice, autoSubscribe: boolean = true) { - super(peripheral, autoSubscribe); + constructor (device: BLEDevice, autoSubscribe: boolean = true) { + super(device, autoSubscribe); this.type = Consts.HubType.WEDO2_SMART_HUB; this._ports = { "A": new Port("A", 1), @@ -312,7 +312,6 @@ export class WeDo2SmartHub extends Hub { private _parseHighCurrentAlert (data: Buffer) { debug("Received Message (WEDO2_HIGH_CURRENT_ALERT)", data); - // console.log(data); }