From b63db06aca56d432541218114e3f60780df3ef82 Mon Sep 17 00:00:00 2001 From: Marek Serafin Date: Mon, 9 Oct 2023 10:21:15 +0200 Subject: [PATCH] Fix start stop handling --- lib/uart.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/uart.js b/lib/uart.js index 66341ea..f63516b 100644 --- a/lib/uart.js +++ b/lib/uart.js @@ -74,7 +74,6 @@ BluetoothHciSocket.prototype.bindUser = function(devId, params) { // Serial Port Parser this._parser = this._serialDevice.pipe(new HciSerialParser()); - this._parser.on('data', (data) => this.emit('data', data)); this._parser.on('raw', this.waitForReset.bind(this)); // Serial Port Event Listeners @@ -119,11 +118,11 @@ BluetoothHciSocket.prototype.isDevUp = function() { }; BluetoothHciSocket.prototype.start = function() { - + this._parser.on('data', (data) => this.emit('data', data)); }; BluetoothHciSocket.prototype.stop = function() { - + this._parser.removeAllListeners('data'); }; BluetoothHciSocket.prototype.write = function(data) { @@ -136,10 +135,6 @@ BluetoothHciSocket.prototype.write = function(data) { BluetoothHciSocket.prototype.waitForReset = function (data) { // if (this._mode === 'raw' && data.length === 7 && ('040e0401030c00' === data.toString('hex') || '040e0402030c00' === data.toString('hex'))) { - // Cleanup - - this._parser.removeListener('raw', this.waitForReset.bind(this)); - debug('reset complete'); this._queue.resume(); this._isUp = true; @@ -156,7 +151,7 @@ BluetoothHciSocket.prototype.reset = function() { // length cmd.writeUInt8(0x00, 3); - debug('reset'); + debug('reset:', cmd.toString("hex")); this._serialDevice.write(cmd); };