Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support node10 #423

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions lib/hci-socket/hci.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var debug = require('debug')('hci');
var events = require('events');
var util = require('util');

var BluetoothHciSocket = require('bluetooth-hci-socket');
var BluetoothHciSocket = require('@abandonware/bluetooth-hci-socket');

var HCI_COMMAND_PKT = 0x01;
var HCI_ACLDATA_PKT = 0x02;
Expand Down Expand Up @@ -118,7 +118,7 @@ Hci.prototype.resetBuffers = function() {
this._handleAclsInProgress = {};
this._handleBuffers = {};
this._aclOutQueue = [];
}
};

Hci.prototype.pollIsDevUp = function() {
var isDevUp = this._socket.isDevUp();
Expand Down Expand Up @@ -146,7 +146,7 @@ Hci.prototype.initDev = function() {
this.readLeHostSupported();
this.readBdAddr();
this.leReadBufferSize();
}
};

Hci.prototype.setSocketFilter = function() {
var filter = new Buffer(14);
Expand Down Expand Up @@ -467,14 +467,14 @@ Hci.prototype.pushAclOutQueue = function() {
debug("\tin progress = " + inProgress);
debug("\twaiting = " + this._aclOutQueue.length);
}
}
};

Hci.prototype.writeOneAclDataPkt = function() {
var pkt = this._aclOutQueue.shift();
this._handleAclsInProgress[pkt.handle]++;
debug('write acl data pkt frag ' + pkt.fragId + ' handle ' + pkt.handle + ' - writing: ' + pkt.pkt.toString('hex'));
this._socket.write(pkt.pkt);
}
};

Hci.prototype.onSocketData = function(data) {
debug('onSocketData: ' + data.toString('hex'));
Expand Down Expand Up @@ -550,22 +550,22 @@ Hci.prototype.onSocketData = function(data) {
this.processLeMetaEvent(leMetaEventType, leMetaEventStatus, leMetaEventData);
} else if (subEventType === EVT_NUMBER_OF_COMPLETED_PACKETS) {
var handles = data.readUInt8(3);
for (var i = 0; i < handles; i++) {
var handle = data.readUInt16LE(4 + i * 4);
var pkts = data.readUInt16LE(6 + i * 4);
debug("\thandle = " + handle);
for (var j = 0; j < handles; j++) {
var handle_ = data.readUInt16LE(4 + j * 4);
var pkts = data.readUInt16LE(6 + j * 4);
debug("\thandle = " + handle_);
debug("\t\tcompleted = " + pkts);
if (this._handleAclsInProgress[handle] === undefined) {
if (this._handleAclsInProgress[handle_] === undefined) {
debug("\t\talready closed");
continue;
}
if (pkts > this._handleAclsInProgress[handle]) {
if (pkts > this._handleAclsInProgress[handle_]) {
// Linux kernel may send acl packets by itself, so be ready for underflow
this._handleAclsInProgress[handle] = 0;
this._handleAclsInProgress[handle_] = 0;
} else {
this._handleAclsInProgress[handle] -= pkts;
this._handleAclsInProgress[handle_] -= pkts;
}
debug("\t\tin progress = " + this._handleAclsInProgress[handle]);
debug("\t\tin progress = " + this._handleAclsInProgress[handle_]);
}
this.pushAclOutQueue();
}
Expand Down Expand Up @@ -712,7 +712,7 @@ Hci.prototype.processLeReadBufferSize = function(result) {
this._aclMtu = aclMtu;
this._aclMaxInProgress = aclMaxInProgress;
}
}
};

Hci.prototype.processLeMetaEvent = function(eventType, status, data) {
if (eventType === EVT_LE_CONN_COMPLETE) {
Expand Down
2 changes: 1 addition & 1 deletion lib/hci-socket/mgmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var debug = require('debug')('mgmt');
var events = require('events');
var util = require('util');

var BluetoothHciSocket = require('bluetooth-hci-socket');
var BluetoothHciSocket = require('@abandonware/bluetooth-hci-socket');

var LTK_INFO_SIZE = 36;

Expand Down
Loading