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

Prevent build upgrades and test Node.js 20 #53

Closed
wants to merge 16 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16,x, 18.x]
node-version: [10.x, 12.x, 14.x, 16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nodepackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-2019]
node_version: [12, 14, 16, 18]
node_version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@master
with:
node-version: 16.0.0
node-version: 18.0.0
- name: Publish if version has been updated
uses: pascalgn/npm-publish-action@master
with: # All of theses inputs are optional
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var bluetoothHciSocket = new BluetoothHciSocket();
#### Set Filter

```javascript
var filter = new Buffer(14);
var filter = Buffer.alloc(14);

// ...

Expand Down Expand Up @@ -155,7 +155,7 @@ __Note:__ must be called after ```bindRaw``` or ```bindControl```.
#### Write

```javascript
var data = new Buffer(/* ... */);
var data = Buffer.from(/* ... */);

// ...

Expand Down
49 changes: 26 additions & 23 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
{
'variables': {
'openssl_fips' : ''
},
'targets': [
{
'target_name': 'bluetooth_hci_socket',
'conditions': [
['OS=="linux" or OS=="android" or OS=="freebsd"', {
'sources': [
'src/BluetoothHciSocket.cpp'
{
'target_name': 'bluetooth_hci_socket',
'conditions': [
['OS=="linux" or OS=="android" or OS=="freebsd"', {
'sources': [
'src/BluetoothHciSocket.cpp'
]
}]
],
"include_dirs" : [
"<!(node -e \"require('nan')\")"
]
}]
],
"include_dirs" : [
"<!(node -e \"require('nan')\")"
},
{
'target_name': 'action_after_build',
'type': 'none',
'dependencies': [ '<(module_name)' ],
'copies': [
{
'files': [ '<(PRODUCT_DIR)/<(module_name).node' ],
'destination': '<(module_path)'
}
]
},
{
'target_name': 'action_after_build',
'type': 'none',
'dependencies': [ '<(module_name)' ],
'copies': [
{
'files': [ '<(PRODUCT_DIR)/<(module_name).node' ],
'destination': '<(module_path)'
}
]
}
]
}
]
}
16 changes: 8 additions & 8 deletions examples/le-advertisement-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var LE_SET_ADVERTISE_ENABLE_CMD = OCF_LE_SET_ADVERTISE_ENABLE | OGF_LE_CTL << 10
var HCI_SUCCESS = 0;

function setFilter() {
var filter = new Buffer(14);
var filter = Buffer.alloc(14);
var typeMask = (1 << HCI_EVENT_PKT) | (1 << HCI_ACLDATA_PKT);
var eventMask1 = (1 << EVT_DISCONN_COMPLETE) | (1 << EVT_CMD_COMPLETE) | (1 << EVT_CMD_STATUS);
var eventMask2 = (1 << (EVT_LE_META_EVENT - 32));
Expand All @@ -131,7 +131,7 @@ function setFilter() {
}

function setAdvertisingParameter() {
var cmd = new Buffer(19);
var cmd = Buffer.alloc(19);

// header
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
Expand All @@ -146,7 +146,7 @@ function setAdvertisingParameter() {
cmd.writeUInt8(0x00, 8); // adv type
cmd.writeUInt8(0x00, 9); // own addr typ
cmd.writeUInt8(0x00, 10); // direct addr type
(new Buffer('000000000000', 'hex')).copy(cmd, 11); // direct addr
(Buffer.from('000000000000', 'hex')).copy(cmd, 11); // direct addr
cmd.writeUInt8(0x07, 17);
cmd.writeUInt8(0x00, 18);

Expand All @@ -155,7 +155,7 @@ function setAdvertisingParameter() {
};

function setAdvertisingData(data) {
var cmd = new Buffer(36);
var cmd = Buffer.alloc(36);

cmd.fill(0);

Expand All @@ -175,7 +175,7 @@ function setAdvertisingData(data) {
}

function setScanResponseData(data) {
var cmd = new Buffer(36);
var cmd = Buffer.alloc(36);

cmd.fill(0);

Expand All @@ -195,7 +195,7 @@ function setScanResponseData(data) {
}

function setAdvertiseEnable(enabled) {
var cmd = new Buffer(5);
var cmd = Buffer.alloc(5);

// header
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
Expand All @@ -219,6 +219,6 @@ console.log('isDevUp = ' + bluetoothHciSocket.isDevUp());

setAdvertiseEnable(false);
setAdvertisingParameter();
setScanResponseData(new Buffer('0909657374696d6f74650e160a182eb8855fb5ddb601000200', 'hex'));
setAdvertisingData(new Buffer('0201061aff4c000215b9407f30f5f8466eaff925556b57fe6d00010002b6', 'hex'));
setScanResponseData(Buffer.from('0909657374696d6f74650e160a182eb8855fb5ddb601000200', 'hex'));
setAdvertisingData(Buffer.from('0201061aff4c000215b9407f30f5f8466eaff925556b57fe6d00010002b6', 'hex'));
setAdvertiseEnable(true);
12 changes: 6 additions & 6 deletions examples/le-connection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bluetoothHciSocket.on('data', function(data) {
console.log('\t' + latency);
console.log('\t' + supervisionTimeout * 10);

writeHandle(handle, new Buffer('020001', 'hex'));
writeHandle(handle, Buffer.from('020001', 'hex'));
}
}
} else if (data.readUInt8(0) === HCI_ACLDATA_PKT) {
Expand Down Expand Up @@ -112,7 +112,7 @@ var HCI_SUCCESS = 0;
var HCI_OE_USER_ENDED_CONNECTION = 0x13;

function setFilter() {
var filter = new Buffer(14);
var filter = Buffer.alloc(14);
var typeMask = (1 << HCI_EVENT_PKT) | (1 << HCI_ACLDATA_PKT);
var eventMask1 = (1 << EVT_DISCONN_COMPLETE) | (1 << EVT_CMD_COMPLETE) | (1 << EVT_CMD_STATUS);
var eventMask2 = (1 << (EVT_LE_META_EVENT - 32));
Expand All @@ -131,7 +131,7 @@ setFilter();
bluetoothHciSocket.start();

function createConnection(address, addressType) {
var cmd = new Buffer(29);
var cmd = Buffer.alloc(29);

// header
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
Expand All @@ -146,7 +146,7 @@ function createConnection(address, addressType) {
cmd.writeUInt8(0x00, 8); // initiator filter

cmd.writeUInt8(addressType === 'random' ? 0x01 : 0x00, 9); // peer address type
(new Buffer(address.split(':').reverse().join(''), 'hex')).copy(cmd, 10); // peer address
(Buffer.from(address.split(':').reverse().join(''), 'hex')).copy(cmd, 10); // peer address

cmd.writeUInt8(0x00, 16); // own address type

Expand All @@ -161,7 +161,7 @@ function createConnection(address, addressType) {
}

function writeHandle(handle, data) {
var cmd = new Buffer(9 + data.length);
var cmd = Buffer.alloc(9 + data.length);

// header
cmd.writeUInt8(HCI_ACLDATA_PKT, 0);
Expand All @@ -176,7 +176,7 @@ function writeHandle(handle, data) {
}

function disconnectConnection(handle, reason) {
var cmd = new Buffer(7);
var cmd = Buffer.alloc(7);

// header
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
Expand Down
6 changes: 3 additions & 3 deletions examples/le-scan-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var LE_SET_SCAN_ENABLE_CMD = OCF_LE_SET_SCAN_ENABLE | OGF_LE_CTL << 10;
var HCI_SUCCESS = 0;

function setFilter() {
var filter = new Buffer(14);
var filter = Buffer.alloc(14);
var typeMask = (1 << HCI_EVENT_PKT);
var eventMask1 = (1 << EVT_CMD_COMPLETE) | (1 << EVT_CMD_STATUS);
var eventMask2 = (1 << (EVT_LE_META_EVENT - 32));
Expand All @@ -84,7 +84,7 @@ function setFilter() {
}

function setScanParameters() {
var cmd = new Buffer(11);
var cmd = Buffer.alloc(11);

// header
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
Expand All @@ -104,7 +104,7 @@ function setScanParameters() {
}

function setScanEnable(enabled, duplicates) {
var cmd = new Buffer(6);
var cmd = Buffer.alloc(6);

// header
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
Expand Down
2 changes: 1 addition & 1 deletion examples/mgmt-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function write(opcode, index, data) {
length += data.length;
}

var pkt = new Buffer(6 + length);
var pkt = Buffer.alloc(6 + length);

pkt.writeUInt16LE(opcode, 0);
pkt.writeUInt16LE(index, 2);
Expand Down
12 changes: 6 additions & 6 deletions lib/usb.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var OCF_RESET = 0x0003;
var VENDOR_DEVICE_LIST = [
{vid: 0x0CF3, pid: 0xE300 }, // Qualcomm Atheros QCA61x4
{vid: 0x0a5c, pid: 0x21e8 }, // Broadcom BCM20702A0
{vid: 0x0a5c, pid: 0x21f1 }, // Broadcom BCM20702A0
{vid: 0x0a5c, pid: 0x21f1 }, // Broadcom BCM20702A0
{vid: 0x19ff, pid: 0x0239 }, // Broadcom BCM20702A0
{vid: 0x413c, pid: 0x8143 }, // Broadcom BCM20702A0
{vid: 0x0a12, pid: 0x0001 }, // CSR
Expand All @@ -33,8 +33,8 @@ var VENDOR_DEVICE_LIST = [
function BluetoothHciSocket() {
this._isUp = false;

this._hciEventEndpointBuffer = new Buffer(0);
this._aclDataInEndpointBuffer = new Buffer(0);
this._hciEventEndpointBuffer = Buffer.alloc(0);
this._aclDataInEndpointBuffer = Buffer.alloc(0);
}

util.inherits(BluetoothHciSocket, events.EventEmitter);
Expand Down Expand Up @@ -246,7 +246,7 @@ BluetoothHciSocket.prototype.onHciEventEndpointData = function(data) {

// fire event
this.emit('data', Buffer.concat([
new Buffer([HCI_EVENT_PKT]),
Buffer.from([HCI_EVENT_PKT]),
buf
]));

Expand Down Expand Up @@ -280,7 +280,7 @@ BluetoothHciSocket.prototype.onAclDataInEndpointData = function(data) {

// fire event
this.emit('data', Buffer.concat([
new Buffer([HCI_ACLDATA_PKT]),
Buffer.from([HCI_ACLDATA_PKT]),
buf
]));

Expand All @@ -290,7 +290,7 @@ BluetoothHciSocket.prototype.onAclDataInEndpointData = function(data) {
};

BluetoothHciSocket.prototype.reset = function() {
var cmd = new Buffer(4);
var cmd = Buffer.alloc(4);

// header
cmd.writeUInt8(HCI_COMMAND_PKT, 0);
Expand Down
Loading
Loading