bluetooth-serial-port 3.0.2 → 3.0.4-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -6
- package/lib/bluetooth-serial-port.js +8 -4
- package/lib/device-inquiry.js +3 -4
- package/package.json +20 -8
- package/prebuilds/bluetooth-serial-port-v3.0.4-node-v108-linux-arm64.tar.gz +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPort.abi108.node +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPort.abi115.node +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPort.abi127.node +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPort.abi137.node +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPortServer.abi108.node +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPortServer.abi115.node +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPortServer.abi127.node +0 -0
- package/prebuilds/linux-x64/BluetoothSerialPortServer.abi137.node +0 -0
- package/prebuilds/win32-x64/BluetoothSerialPort.abi108.node +0 -0
- package/prebuilds/win32-x64/BluetoothSerialPort.abi115.node +0 -0
- package/prebuilds/win32-x64/BluetoothSerialPort.abi127.node +0 -0
- package/prebuilds/win32-x64/BluetoothSerialPort.abi137.node +0 -0
- package/scripts/create-prebuilds.js +42 -0
- package/scripts/download-prebuilds.js +98 -0
- package/scripts/load-native.js +39 -0
- package/src/linux/BTSerialPortBinding.cc +1 -0
- package/src/linux/DeviceINQ.cc +7 -1
- package/src/windows/BTSerialPortBinding.cc +1 -0
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv.h +0 -1724
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv.h.blob +0 -0
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@darwin.h +0 -61
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@darwin.h.blob +0 -0
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@errno.h +0 -443
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@errno.h.blob +0 -0
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@threadpool.h +0 -37
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@threadpool.h.blob +0 -0
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@unix.h +0 -491
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@unix.h.blob +0 -0
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@version.h +0 -43
- package/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv@version.h.blob +0 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@DeviceINQ.h +0 -78
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@DeviceINQ.h.blob +0 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@BTSerialPortBinding.cc +0 -404
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@BTSerialPortBinding.cc.blob +0 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@BluetoothSerialPort.cc +0 -23
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@BluetoothSerialPort.cc.blob +0 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@DeviceINQ.cc +0 -369
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@DeviceINQ.cc.blob +0 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@windows@BluetoothHelpers.h +0 -24
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@windows@BluetoothHelpers.h.blob +0 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@windows@DeviceINQ.cc +0 -527
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@windows@DeviceINQ.cc.blob +0 -0
- package/.circleci/config.yml +0 -47
- package/.github/dependabot.yml +0 -11
- package/Dockerfile +0 -6
- package/Dockerfile.bk +0 -13
- package/RELEASE_NOTES.md +0 -212
- package/appveyor.yml +0 -38
- package/examples/async.js +0 -15
- package/examples/paired.js +0 -5
- package/examples/sync.js +0 -15
- package/qemu-arm-static +0 -0
- package/test/index.js +0 -32
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ This piece of open source software is free (as in speech) to [use, modify and di
|
|
|
6
6
|
|
|
7
7
|
> MacOS support has (temporarily) been dropped as of version v3.0.0 of the module. If you use the module on a Mac please stay on v2 of this module.
|
|
8
8
|
|
|
9
|
-
> _DEPRECATED_
|
|
9
|
+
> _DEPRECATED_ I am no longer actively maintaining this project. If you want to help out by adding support please contact me. It was a great experience maintaining this project for almost 8 years. It was great to see people step in to improve this project. Thank you all!
|
|
10
10
|
|
|
11
11
|
[](https://dl.circleci.com/status-badge/redirect/gh/eelcocramer/node-bluetooth-serial-port/tree/master)
|
|
12
12
|
[](https://ci.appveyor.com/project/eelcocramer/node-bluetooth-serial-port)
|
|
@@ -15,15 +15,19 @@ This node module lets you communicate over Bluetooth serial port with devices us
|
|
|
15
15
|
|
|
16
16
|
If you have any problems make sure to [checkout the FAQ](https://github.com/eelcocramer/node-bluetooth-serial-port/issues?q=label%3AFAQ).
|
|
17
17
|
|
|
18
|
-
## New in the last
|
|
18
|
+
## New in the last releases
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
* Downloads precompiled native assets from github
|
|
21
|
+
* Bumps dependencies
|
|
22
|
+
* Fixes memory leaks.
|
|
23
|
+
* Adds support for node 20, 22 and 24
|
|
21
24
|
|
|
22
25
|
Check the [release notes](RELEASE_NOTES.md) for an overview of the change history.
|
|
23
26
|
|
|
24
27
|
## Prerequisites on Linux
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
* Build prerequisites are only needed when no matching prebuilt binary is available.
|
|
30
|
+
* Needs Bluetooth development packages for source builds.
|
|
27
31
|
|
|
28
32
|
`apt-get install build-essential libbluetooth-dev`
|
|
29
33
|
|
|
@@ -52,13 +56,17 @@ sudo systemctl restart bluetooth
|
|
|
52
56
|
|
|
53
57
|
## Prerequisites on Windows
|
|
54
58
|
|
|
55
|
-
-
|
|
56
|
-
- Needs
|
|
59
|
+
- Build prerequisites are only needed when no matching prebuilt binary is available.
|
|
60
|
+
- Needs Visual Studio (Visual C++) and its command line tools for source builds.
|
|
61
|
+
- Needs Python installed and accessible from the command line path.
|
|
57
62
|
|
|
58
63
|
## Install
|
|
59
64
|
|
|
60
65
|
`npm install bluetooth-serial-port`
|
|
61
66
|
|
|
67
|
+
For Linux x64 and Windows x64 on Node 18, 20, 22 and 24, installation first downloads a prebuilt native binary from GitHub Releases.
|
|
68
|
+
If a matching prebuild is unavailable, install falls back to a local `node-gyp` build.
|
|
69
|
+
|
|
62
70
|
## Test build Linux using docker
|
|
63
71
|
|
|
64
72
|
`docker build -t bluetooth-serial-port .`
|
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
(function () {
|
|
16
16
|
"use strict";
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var path = require('path'),
|
|
19
|
+
util = require('util'),
|
|
19
20
|
EventEmitter = require('events').EventEmitter,
|
|
20
|
-
|
|
21
|
+
loadNative = require('../scripts/load-native'),
|
|
22
|
+
btSerial = loadNative(path.join(__dirname, '..'), 'BluetoothSerialPort'),
|
|
21
23
|
DeviceINQ = require("./device-inquiry.js").DeviceINQ;
|
|
22
24
|
|
|
23
25
|
/**
|
|
@@ -143,9 +145,11 @@
|
|
|
143
145
|
return;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
var
|
|
148
|
+
var path = require('path'),
|
|
149
|
+
util = require('util'),
|
|
147
150
|
EventEmitter = require('events').EventEmitter,
|
|
148
|
-
|
|
151
|
+
loadNative = require('../scripts/load-native'),
|
|
152
|
+
btSerial = loadNative(path.join(__dirname, '..'), 'BluetoothSerialPortServer'),
|
|
149
153
|
_SERIAL_PORT_PROFILE_UUID = '1101',
|
|
150
154
|
_DEFAULT_SERVER_CHANNEL = 1,
|
|
151
155
|
_ERROR_CLIENT_CLOSED_CONNECTION = 'Error: Connection closed by the client';
|
package/lib/device-inquiry.js
CHANGED
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
(function () {
|
|
16
16
|
"use strict";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
var path = require('path'),
|
|
19
|
+
loadNative = require('../scripts/load-native'),
|
|
20
|
+
DeviceINQ = loadNative(path.join(__dirname, '..'), 'BluetoothSerialPort').DeviceINQ,
|
|
20
21
|
events = require('events');
|
|
21
22
|
|
|
22
|
-
// extend prototype
|
|
23
23
|
function inherits(target, source) {
|
|
24
24
|
var k;
|
|
25
|
-
|
|
26
25
|
for (k in source.prototype) {
|
|
27
26
|
target.prototype[k] = source.prototype[k];
|
|
28
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bluetooth-serial-port",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4-beta.11",
|
|
4
4
|
"description": "Bluetooth serial port communication for Node.js",
|
|
5
5
|
"author": "Eelco Cramer <eelco@hailendal.org>",
|
|
6
6
|
"keywords": [
|
|
@@ -14,32 +14,44 @@
|
|
|
14
14
|
"bugs": "https://github.com/eelcocramer/node-bluetooth-serial-port/issues",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/eelcocramer/node-bluetooth-serial-port"
|
|
17
|
+
"url": "git+https://github.com/eelcocramer/node-bluetooth-serial-port.git"
|
|
18
18
|
},
|
|
19
19
|
"directories": {
|
|
20
20
|
"lib": "./lib"
|
|
21
21
|
},
|
|
22
22
|
"main": "./lib/bluetooth-serial-port.js",
|
|
23
23
|
"types": "./lib/bluetooth-serial-port.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"lib/",
|
|
26
|
+
"src/",
|
|
27
|
+
"scripts/",
|
|
28
|
+
"binding.gyp",
|
|
29
|
+
"prebuilds/"
|
|
30
|
+
],
|
|
24
31
|
"os": [
|
|
25
32
|
"linux",
|
|
26
33
|
"win32"
|
|
27
34
|
],
|
|
28
35
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
36
|
+
"nan": "^2.28.0",
|
|
37
|
+
"node-gyp-build": "^4.8.4",
|
|
31
38
|
"stable": "^0.1.8"
|
|
32
39
|
},
|
|
40
|
+
"devDependencies": {},
|
|
33
41
|
"optionalDependencies": {
|
|
34
|
-
"@types/node": "^
|
|
42
|
+
"@types/node": "^26.1.2"
|
|
35
43
|
},
|
|
36
44
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
45
|
+
"node": ">= 18.x",
|
|
38
46
|
"npm": ">= 8.x"
|
|
39
47
|
},
|
|
40
48
|
"scripts": {
|
|
41
|
-
"install": "node-gyp
|
|
42
|
-
"install-
|
|
49
|
+
"install": "node-gyp-build",
|
|
50
|
+
"install-release": "node-gyp configure build",
|
|
51
|
+
"install-debug": "node-gyp configure build --debug",
|
|
52
|
+
"prebuild": "node scripts/create-prebuilds.js --strip",
|
|
53
|
+
"prepublishOnly": "node scripts/download-prebuilds.js",
|
|
54
|
+
"test": "node test/index.js"
|
|
43
55
|
},
|
|
44
56
|
"license": "MIT",
|
|
45
57
|
"contributors": [
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// scripts/create-prebuilds.js
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var cp = require('child_process');
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
|
|
8
|
+
var strip = process.argv.includes('--strip');
|
|
9
|
+
var abi = process.versions.modules;
|
|
10
|
+
var platform = process.platform;
|
|
11
|
+
var arch = process.arch;
|
|
12
|
+
var rootDir = path.join(__dirname, '..');
|
|
13
|
+
var releaseDir = path.join(rootDir, 'build', 'Release');
|
|
14
|
+
var outDir = path.join(rootDir, 'prebuilds', platform + '-' + arch);
|
|
15
|
+
var modules = ['BluetoothSerialPort'];
|
|
16
|
+
if (platform === 'linux') {
|
|
17
|
+
modules.push('BluetoothSerialPortServer');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
21
|
+
|
|
22
|
+
modules.forEach(function(name) {
|
|
23
|
+
var src = path.join(releaseDir, name + '.node');
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(src)) {
|
|
26
|
+
console.error('Error: ' + src + ' not found. Run "npm run install-release" first.');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var dest = path.join(outDir, name + '.abi' + abi + '.node');
|
|
31
|
+
fs.copyFileSync(src, dest);
|
|
32
|
+
|
|
33
|
+
if (strip && platform !== 'win32') {
|
|
34
|
+
try {
|
|
35
|
+
cp.execSync('strip "' + dest + '"', { stdio: 'inherit' });
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.warn('Warning: strip failed for ' + dest + ' (' + e.message + ')');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log('Created ' + path.relative(rootDir, dest));
|
|
42
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// scripts/download-prebuilds.js
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
|
|
7
|
+
var pkg = require('../package.json');
|
|
8
|
+
var token = process.env.GITHUB_TOKEN;
|
|
9
|
+
|
|
10
|
+
// Parse owner/repo from repository.url
|
|
11
|
+
// Handles: https://github.com/owner/repo or git+https://github.com/owner/repo
|
|
12
|
+
var repoMatch = pkg.repository.url.match(/github\.com[/:]([^/]+)\/([^/.]+)/);
|
|
13
|
+
if (!repoMatch) {
|
|
14
|
+
console.error('Error: Cannot parse GitHub owner/repo from: ' + pkg.repository.url);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
var owner = repoMatch[1];
|
|
18
|
+
var repo = repoMatch[2].replace(/\.git$/, '');
|
|
19
|
+
var tag = 'v' + pkg.version;
|
|
20
|
+
var rootDir = path.join(__dirname, '..');
|
|
21
|
+
|
|
22
|
+
console.log('Downloading prebuilds for ' + owner + '/' + repo + '@' + tag + '...');
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
var apiUrl = 'https://api.github.com/repos/' + owner + '/' + repo + '/releases/tags/' + tag;
|
|
26
|
+
var headers = {
|
|
27
|
+
'Accept': 'application/vnd.github.v3+json',
|
|
28
|
+
'User-Agent': repo + '-prebuild-downloader'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (token) {
|
|
32
|
+
headers.Authorization = 'Bearer ' + token;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var apiRes = await fetch(apiUrl, {
|
|
36
|
+
headers: headers
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!apiRes.ok) {
|
|
40
|
+
var body = await apiRes.text();
|
|
41
|
+
throw new Error('GitHub API ' + apiRes.status + ' for ' + apiUrl + ': ' + body);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var release = await apiRes.json();
|
|
45
|
+
var assets = release.assets.filter(function(a) { return /\.abi\d+\.node$/.test(a.name); });
|
|
46
|
+
|
|
47
|
+
if (assets.length === 0) {
|
|
48
|
+
console.error(
|
|
49
|
+
'Error: No prebuilt binaries found in GitHub Release ' + tag + '.\n' +
|
|
50
|
+
'Wait for CI to finish uploading prebuilts before running npm publish.'
|
|
51
|
+
);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log('Found ' + assets.length + ' prebuild asset(s).');
|
|
56
|
+
|
|
57
|
+
for (var asset of assets) {
|
|
58
|
+
// Asset name format: linux-x64--BluetoothSerialPort.abi108.node
|
|
59
|
+
var sep = asset.name.indexOf('--');
|
|
60
|
+
if (sep === -1) {
|
|
61
|
+
console.warn('Skipping unrecognised asset name: ' + asset.name);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
var platformArch = asset.name.slice(0, sep);
|
|
65
|
+
var filename = asset.name.slice(sep + 2);
|
|
66
|
+
var destDir = path.join(rootDir, 'prebuilds', platformArch);
|
|
67
|
+
var destFile = path.join(destDir, filename);
|
|
68
|
+
|
|
69
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
70
|
+
|
|
71
|
+
var dlHeaders = {
|
|
72
|
+
'User-Agent': repo + '-prebuild-downloader'
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
if (token) {
|
|
76
|
+
dlHeaders.Authorization = 'Bearer ' + token;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var dlRes = await fetch(asset.browser_download_url, {
|
|
80
|
+
headers: dlHeaders
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (!dlRes.ok) {
|
|
84
|
+
throw new Error('Download failed for ' + asset.name + ': HTTP ' + dlRes.status);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var buf = await dlRes.arrayBuffer();
|
|
88
|
+
fs.writeFileSync(destFile, Buffer.from(buf));
|
|
89
|
+
console.log(' -> ' + path.relative(rootDir, destFile));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log('All prebuilds downloaded successfully.');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
main().catch(function(err) {
|
|
96
|
+
console.error('Error:', err.message);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// scripts/load-native.js
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Loads a named native module (.node file).
|
|
9
|
+
* Resolution order:
|
|
10
|
+
* 1. prebuilds/{platform}-{arch}/{name}.abi{abi}.node (bundled prebuild)
|
|
11
|
+
* 2. build/Release/{name}.node (source-compiled release)
|
|
12
|
+
* 3. build/Debug/{name}.node (source-compiled debug)
|
|
13
|
+
*
|
|
14
|
+
* @param {string} packageRoot Absolute path to the package root directory.
|
|
15
|
+
* @param {string} name Module name without extension (e.g. 'BluetoothSerialPort').
|
|
16
|
+
* @returns {object} The native binding.
|
|
17
|
+
*/
|
|
18
|
+
module.exports = function loadNative(packageRoot, name) {
|
|
19
|
+
var abi = process.versions.modules;
|
|
20
|
+
var platform = process.platform;
|
|
21
|
+
var arch = process.arch;
|
|
22
|
+
|
|
23
|
+
var candidates = [
|
|
24
|
+
path.join(packageRoot, 'prebuilds', platform + '-' + arch, name + '.abi' + abi + '.node'),
|
|
25
|
+
path.join(packageRoot, 'build', 'Release', name + '.node'),
|
|
26
|
+
path.join(packageRoot, 'build', 'Debug', name + '.node')
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
for (var i = 0; i < candidates.length; i++) {
|
|
30
|
+
if (fs.existsSync(candidates[i])) {
|
|
31
|
+
return require(candidates[i]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
throw new Error(
|
|
36
|
+
'Could not find native module "' + name + '". Searched:\n' +
|
|
37
|
+
candidates.map(function(p) { return ' ' + p; }).join('\n')
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -391,6 +391,7 @@ NAN_METHOD(BTSerialPortBinding::Read) {
|
|
|
391
391
|
Nan::AsyncResource resource("bluetooth-serial-port:Read");
|
|
392
392
|
Nan::Callback *nc = new Nan::Callback(cb);
|
|
393
393
|
nc->Call(2, argv, &resource);
|
|
394
|
+
delete nc;
|
|
394
395
|
} else {
|
|
395
396
|
read_baton_t *baton = new read_baton_t();
|
|
396
397
|
baton->rfcomm = rfcomm;
|
package/src/linux/DeviceINQ.cc
CHANGED
|
@@ -252,9 +252,12 @@ NAN_METHOD(DeviceINQ::InquireSync) {
|
|
|
252
252
|
};
|
|
253
253
|
found->Call(2, argv, &resource);
|
|
254
254
|
}
|
|
255
|
+
free(inquiryResult.devices);
|
|
255
256
|
|
|
256
257
|
Local<Value> argv[] = {};
|
|
257
258
|
callback->Call(0, argv, &resource);
|
|
259
|
+
delete callback;
|
|
260
|
+
delete found;
|
|
258
261
|
return;
|
|
259
262
|
}
|
|
260
263
|
|
|
@@ -262,7 +265,9 @@ class InquireWorker : public Nan::AsyncWorker {
|
|
|
262
265
|
public:
|
|
263
266
|
InquireWorker(Nan::Callback* found, Nan::Callback *callback)
|
|
264
267
|
: Nan::AsyncWorker(callback), found(found) {}
|
|
265
|
-
~InquireWorker() {
|
|
268
|
+
~InquireWorker() {
|
|
269
|
+
delete found;
|
|
270
|
+
}
|
|
266
271
|
|
|
267
272
|
// Executed inside the worker-thread.
|
|
268
273
|
// It is not safe to access V8, or V8 data structures
|
|
@@ -289,6 +294,7 @@ class InquireWorker : public Nan::AsyncWorker {
|
|
|
289
294
|
|
|
290
295
|
Local<Value> argv[] = {};
|
|
291
296
|
callback->Call(0, argv, &resource);
|
|
297
|
+
free(inquiryResult.devices);
|
|
292
298
|
}
|
|
293
299
|
|
|
294
300
|
private:
|
|
@@ -354,6 +354,7 @@ NAN_METHOD(BTSerialPortBinding::Read) {
|
|
|
354
354
|
Nan::AsyncResource resource("bluetooth-serial-port:Read");
|
|
355
355
|
Nan::Callback *nc = new Nan::Callback(cb);
|
|
356
356
|
nc->Call(2, argv, &resource);
|
|
357
|
+
delete nc;
|
|
357
358
|
} else {
|
|
358
359
|
read_baton_t *baton = new read_baton_t();
|
|
359
360
|
baton->rfcomm = rfcomm;
|