bluetooth-serial-port 2.2.5 → 3.0.0
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/.ccls-cache/@@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/@usr@local@Cellar@libuv@1.31.0@include@uv.h +1724 -0
- 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 +61 -0
- 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 +443 -0
- 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 +37 -0
- 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 +491 -0
- 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 +43 -0
- 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 +78 -0
- 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 +404 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@BTSerialPortBinding.cc.blob +0 -0
- package/{src/osx/BluetoothSerialPort.mm → .ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@linux@BluetoothSerialPort.cc} +3 -3
- 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 +369 -0
- 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 +24 -0
- 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 +527 -0
- package/.ccls-cache/@Users@eelco@Projects@Figaro@workspace@node-bluetooth-serial-port/src@windows@DeviceINQ.cc.blob +0 -0
- package/.circleci/config.yml +47 -0
- package/.github/dependabot.yml +11 -0
- package/Dockerfile +1 -1
- package/Dockerfile.bk +13 -0
- package/README.md +91 -78
- package/RELEASE_NOTES.md +14 -0
- package/appveyor.yml +6 -9
- package/binding.gyp +0 -8
- package/package.json +56 -58
- package/qemu-arm-static +0 -0
- package/src/BTSerialPortBinding.h +3 -3
- package/src/BTSerialPortBindingServer.h +1 -1
- package/src/DeviceINQ.h +1 -1
- package/src/linux/BTSerialPortBinding.cc +17 -15
- package/src/linux/BTSerialPortBindingServer.cc +29 -19
- package/src/linux/BluetoothSerialPort.cc +1 -1
- package/src/linux/BluetoothSerialPortServer.cc +1 -1
- package/src/linux/DeviceINQ.cc +18 -15
- package/src/{osx → macos}/BTSerialPortBinding.mm +23 -17
- package/src/{osx → macos}/BluetoothDeviceResources.h +0 -0
- package/src/{osx → macos}/BluetoothDeviceResources.mm +0 -0
- package/src/macos/BluetoothSerialPort.mm +23 -0
- package/src/{osx → macos}/BluetoothWorker.h +3 -3
- package/src/{osx → macos}/BluetoothWorker.mm +139 -140
- package/src/{osx → macos}/DeviceINQ.mm +21 -23
- package/src/{osx → macos}/pipe.c +0 -0
- package/src/{osx → macos}/pipe.h +0 -0
- package/src/windows/BTSerialPortBinding.cc +17 -18
- package/src/windows/BluetoothSerialPort.cc +3 -3
- package/src/windows/DeviceINQ.cc +17 -15
- package/.travis.yml +0 -48
package/README.md
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
# Bluetooth serial port communication for Node.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> MacOS support has (temporarely) 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.
|
|
4
|
+
|
|
5
|
+
> _DEPRECATED_ Currently I have no plans to add support for nodejs version 1.13 and up. 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!
|
|
6
|
+
|
|
7
|
+
[](https://dl.circleci.com/status-badge/redirect/gh/eelcocramer/node-bluetooth-serial-port/tree/master)
|
|
4
8
|
[](https://ci.appveyor.com/project/eelcocramer/node-bluetooth-serial-port)
|
|
5
9
|
|
|
6
|
-
This node module lets you communicate over Bluetooth serial port with devices using
|
|
10
|
+
This node module lets you communicate over Bluetooth serial port with devices using NodeJS. The goal is have an easy to use API. This module is great for communicating with Bluetooth enabled Arduino devices.
|
|
7
11
|
|
|
8
12
|
If you have any problems make sure to [checkout the FAQ](https://github.com/eelcocramer/node-bluetooth-serial-port/issues?q=label%3AFAQ).
|
|
9
13
|
|
|
10
14
|
## New in the last release
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
- Changes node version to `lts` in the Dockerfile
|
|
13
17
|
|
|
14
18
|
Check the [release notes](RELEASE_NOTES.md) for an overview of the change history.
|
|
15
19
|
|
|
16
20
|
## Prerequisites on Linux
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
- Needs Bluetooth development packages to build
|
|
19
23
|
|
|
20
24
|
`apt-get install build-essential libbluetooth-dev`
|
|
21
25
|
|
|
22
26
|
### Note on RFCOMM Server Sockets
|
|
23
|
-
|
|
27
|
+
|
|
28
|
+
As the initial implementation of the RFCOMM server sockets is based on BlueZ4, in order to work with SDP we need to change the bluetooth service configuration file by modifing the systemd unit file: bluetooth.service:
|
|
24
29
|
|
|
25
30
|
(Debian based distro)
|
|
26
31
|
|
|
@@ -41,14 +46,10 @@ sudo systemctl daemon-reload
|
|
|
41
46
|
sudo systemctl restart bluetooth
|
|
42
47
|
```
|
|
43
48
|
|
|
44
|
-
## Prerequisites on macOS
|
|
45
|
-
|
|
46
|
-
* Needs Xcode and Xcode command line tools installed.
|
|
47
|
-
|
|
48
49
|
## Prerequisites on Windows
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
- Needs Visual Studio (Visual C++) and its command line tools installed.
|
|
52
|
+
- Needs Python 2.x installed and accessible from the command line path.
|
|
52
53
|
|
|
53
54
|
## Install
|
|
54
55
|
|
|
@@ -63,64 +64,78 @@ sudo systemctl restart bluetooth
|
|
|
63
64
|
## Basic client usage
|
|
64
65
|
|
|
65
66
|
```javascript
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
btSerial.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
var btSerial = new (require("bluetooth-serial-port").BluetoothSerialPort)();
|
|
68
|
+
|
|
69
|
+
btSerial.on("found", function (address, name) {
|
|
70
|
+
btSerial.findSerialPortChannel(
|
|
71
|
+
address,
|
|
72
|
+
function (channel) {
|
|
73
|
+
btSerial.connect(
|
|
74
|
+
address,
|
|
75
|
+
channel,
|
|
76
|
+
function () {
|
|
77
|
+
console.log("connected");
|
|
78
|
+
|
|
79
|
+
btSerial.write(
|
|
80
|
+
Buffer.from("my data", "utf-8"),
|
|
81
|
+
function (err, bytesWritten) {
|
|
82
|
+
if (err) console.log(err);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
btSerial.on("data", function (buffer) {
|
|
87
|
+
console.log(buffer.toString("utf-8"));
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
function () {
|
|
91
|
+
console.log("cannot connect");
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// close the connection when you're ready
|
|
96
|
+
btSerial.close();
|
|
97
|
+
},
|
|
98
|
+
function () {
|
|
99
|
+
console.log("found nothing");
|
|
100
|
+
}
|
|
101
|
+
);
|
|
90
102
|
});
|
|
91
103
|
|
|
92
104
|
btSerial.inquire();
|
|
93
|
-
|
|
94
105
|
```
|
|
95
106
|
|
|
96
107
|
## Basic server usage (only on Linux)
|
|
97
108
|
|
|
98
109
|
```javascript
|
|
99
|
-
var server = new(require(
|
|
110
|
+
var server = new (require("bluetooth-serial-port").BluetoothSerialPortServer)();
|
|
100
111
|
|
|
101
112
|
var CHANNEL = 10; // My service channel. Defaults to 1 if omitted.
|
|
102
|
-
var UUID =
|
|
113
|
+
var UUID = "38e851bc-7144-44b4-9cd8-80549c6f2912"; // My own service UUID. Defaults to '1101' if omitted
|
|
103
114
|
|
|
104
|
-
server.on(
|
|
105
|
-
console.log(
|
|
115
|
+
server.on("data", function (buffer) {
|
|
116
|
+
console.log("Received data from client: " + buffer);
|
|
106
117
|
|
|
107
118
|
// ...
|
|
108
119
|
|
|
109
|
-
console.log(
|
|
110
|
-
server.write(Buffer.from(
|
|
120
|
+
console.log("Sending data to the client");
|
|
121
|
+
server.write(Buffer.from("..."), function (err, bytesWritten) {
|
|
111
122
|
if (err) {
|
|
112
|
-
console.log(
|
|
123
|
+
console.log("Error!");
|
|
113
124
|
} else {
|
|
114
|
-
console.log(
|
|
125
|
+
console.log("Send " + bytesWritten + " to the client!");
|
|
115
126
|
}
|
|
116
127
|
});
|
|
117
128
|
});
|
|
118
129
|
|
|
119
|
-
server.listen(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
130
|
+
server.listen(
|
|
131
|
+
function (clientAddress) {
|
|
132
|
+
console.log("Client: " + clientAddress + " connected!");
|
|
133
|
+
},
|
|
134
|
+
function (error) {
|
|
135
|
+
console.error("Something wrong happened!:" + error);
|
|
136
|
+
},
|
|
137
|
+
{ uuid: UUID, channel: CHANNEL }
|
|
138
|
+
);
|
|
124
139
|
```
|
|
125
140
|
|
|
126
141
|
## API
|
|
@@ -131,7 +146,7 @@ server.listen(function (clientAddress) {
|
|
|
131
146
|
|
|
132
147
|
Emitted when data is read from the serial port connection.
|
|
133
148
|
|
|
134
|
-
|
|
149
|
+
- buffer - the data that was read into a [Buffer](http://nodejs.org/api/buffer.html) object.
|
|
135
150
|
|
|
136
151
|
#### Event: ('closed')
|
|
137
152
|
|
|
@@ -141,14 +156,14 @@ Emitted when a connection was closed either by the user (i.e. calling `close` or
|
|
|
141
156
|
|
|
142
157
|
Emitted when reading from the serial port connection results in an error. The connection is closed.
|
|
143
158
|
|
|
144
|
-
|
|
159
|
+
- err - an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object) describing the failure.
|
|
145
160
|
|
|
146
161
|
#### Event: ('found', address, name)
|
|
147
162
|
|
|
148
163
|
Emitted when a bluetooth device was found.
|
|
149
164
|
|
|
150
|
-
|
|
151
|
-
|
|
165
|
+
- address - the address of the device
|
|
166
|
+
- name - the name of the device (or the address if the name is unavailable)
|
|
152
167
|
|
|
153
168
|
#### Event: ('finished')
|
|
154
169
|
|
|
@@ -166,14 +181,14 @@ Starts searching synchronously for bluetooth devices. When a device is found a '
|
|
|
166
181
|
|
|
167
182
|
Checks if a device has a serial port service running and if it is found it passes the channel id to use for the RFCOMM connection.
|
|
168
183
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
Connects to a remote bluetooth device.
|
|
184
|
+
- callback(channel) - called when finished looking for a serial port on the device.
|
|
185
|
+
- errorCallback - called the search finished but no serial port channel was found on the device.
|
|
186
|
+
Connects to a remote bluetooth device.
|
|
172
187
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
188
|
+
- bluetoothAddress - the address of the remote Bluetooth device.
|
|
189
|
+
- channel - the channel to connect to.
|
|
190
|
+
- [successCallback] - called when a connection has been established.
|
|
191
|
+
- [errorCallback(err)] - called when the connection attempt results in an error. The parameter is an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object).
|
|
177
192
|
|
|
178
193
|
#### BluetoothSerialPort.close()
|
|
179
194
|
|
|
@@ -187,16 +202,16 @@ Check whether the connection is open or not.
|
|
|
187
202
|
|
|
188
203
|
Writes a [Buffer](http://nodejs.org/api/buffer.html) to the serial port connection.
|
|
189
204
|
|
|
190
|
-
|
|
191
|
-
|
|
205
|
+
- buffer - the [Buffer](http://nodejs.org/api/buffer.html) to be written.
|
|
206
|
+
- callback(err, bytesWritten) - is called when the write action has been completed. When the `err` parameter is set an error has occured, in that case `err` is an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object). When `err` is not set the write action was successful and `bytesWritten` contains the amount of bytes that is written to the connection.
|
|
192
207
|
|
|
193
208
|
#### BluetoothSerialPort.listPairedDevices(callback)
|
|
194
209
|
|
|
195
|
-
|
|
210
|
+
**NOT AVAILABLE ON LINUX**
|
|
196
211
|
|
|
197
212
|
Lists the devices that are currently paired with the host.
|
|
198
213
|
|
|
199
|
-
|
|
214
|
+
- callback(pairedDevices) - is called when the paired devices object has been populated. See the [pull request](https://github.com/eelcocramer/node-bluetooth-serial-port/pull/30) for more information on the `pairedDevices` object.
|
|
200
215
|
|
|
201
216
|
### BluetoothSerialPortServer
|
|
202
217
|
|
|
@@ -204,24 +219,22 @@ Lists the devices that are currently paired with the host.
|
|
|
204
219
|
|
|
205
220
|
Listens for an incoming bluetooth connection. It will automatically advertise the server via SDP
|
|
206
221
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
- callback(address) - is called when a new client is connecting.
|
|
223
|
+
- errorCallback(err) - is called when an error occurs.
|
|
224
|
+
- options - An object with these properties:
|
|
225
|
+
|
|
226
|
+
- uuid - [String] The UUID of the server. If omitted the default value will be 1101 (corresponding to Serial Port Profile UUID). Can be a 16 bit or 32 bit UUID.
|
|
227
|
+
- channel - [Number] The RFCOMM channel the server is listening on, in the range of 1-30. If omitted the default value will be 1.
|
|
212
228
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
uuid: 'ffffffff-ffff-ffff-ffff-fffffffffff1',
|
|
216
|
-
channel: 10
|
|
217
|
-
}`
|
|
229
|
+
Example:
|
|
230
|
+
`var options = { uuid: 'ffffffff-ffff-ffff-ffff-fffffffffff1', channel: 10 }`
|
|
218
231
|
|
|
219
232
|
#### BluetoothSerialPortServer.write(buffer, callback)
|
|
220
233
|
|
|
221
234
|
Writes data from a buffer to a connection.
|
|
222
235
|
|
|
223
|
-
|
|
224
|
-
|
|
236
|
+
- buffer - the buffer to send over the connection.
|
|
237
|
+
- callback(err, len) - called when the data is send or an error did occur. `error` contains the error is appropriated. `len` has the number of bytes that were written to the connection.
|
|
225
238
|
|
|
226
239
|
#### BluetoothSerialPortServer.close()
|
|
227
240
|
|
|
@@ -239,7 +252,7 @@ Checks is a server is listening or not.
|
|
|
239
252
|
|
|
240
253
|
Emitted when data is read from the serial port connection.
|
|
241
254
|
|
|
242
|
-
|
|
255
|
+
- buffer - the data that was read into a [Buffer](http://nodejs.org/api/buffer.html) object.
|
|
243
256
|
|
|
244
257
|
#### Event: ('disconnected')
|
|
245
258
|
|
|
@@ -253,7 +266,7 @@ Emitted when the server is closed (i.e. from calling `close` or as the result of
|
|
|
253
266
|
|
|
254
267
|
Emitted when reading from the serial port connection results in an error. The connection is closed.
|
|
255
268
|
|
|
256
|
-
|
|
269
|
+
- err - an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object) describing the failure.
|
|
257
270
|
|
|
258
271
|
## Typescript support
|
|
259
272
|
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
## RELEASE NOTES
|
|
2
2
|
|
|
3
|
+
### 3.0.0
|
|
4
|
+
|
|
5
|
+
* Fixes building issues with recent version of NodeJS.
|
|
6
|
+
* Drops support for Darwin / MacOS for the moment. If you want to use the module on a Mac please install v2.2.7.
|
|
7
|
+
|
|
8
|
+
### 2.2.7
|
|
9
|
+
|
|
10
|
+
* Changes node version to `lts` in the Dockerfile
|
|
11
|
+
|
|
12
|
+
### 2.2.6
|
|
13
|
+
|
|
14
|
+
* Adds support for node v12
|
|
15
|
+
* Node v6 and v7 are no longer supported
|
|
16
|
+
|
|
3
17
|
### 2.2.5
|
|
4
18
|
|
|
5
19
|
* Fixes issue #97 where the server process does not exit correctly.
|
package/appveyor.yml
CHANGED
|
@@ -4,15 +4,12 @@ environment:
|
|
|
4
4
|
# Test against these versions of Node.js and io.js
|
|
5
5
|
matrix:
|
|
6
6
|
# node.js
|
|
7
|
-
- nodejs_version: "
|
|
8
|
-
- nodejs_version: "
|
|
9
|
-
- nodejs_version: "
|
|
10
|
-
|
|
11
|
-
- nodejs_version: "10"
|
|
12
|
-
- nodejs_version: "11"
|
|
7
|
+
- nodejs_version: "14"
|
|
8
|
+
- nodejs_version: "16"
|
|
9
|
+
- nodejs_version: "18"
|
|
10
|
+
|
|
13
11
|
|
|
14
12
|
platform:
|
|
15
|
-
- x86
|
|
16
13
|
- x64
|
|
17
14
|
|
|
18
15
|
# Install scripts. (runs after repo cloning)
|
|
@@ -24,8 +21,8 @@ install:
|
|
|
24
21
|
- npm -g install npm@latest
|
|
25
22
|
- npm --version
|
|
26
23
|
- node -e "console.log(process.arch);"
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
#- if "%PLATFORM%" == "x64" SET PATH=C:\Python27-x64;%PATH%
|
|
25
|
+
#- if "%PLATFORM%" == "x86" SET PATH=C:\python27;%PATH%
|
|
29
26
|
- npm install node-gyp
|
|
30
27
|
- npm update
|
|
31
28
|
- npm run install-debug
|
package/binding.gyp
CHANGED
|
@@ -11,14 +11,6 @@
|
|
|
11
11
|
'libraries': ['-lbluetooth'],
|
|
12
12
|
'cflags':['-std=c++11']
|
|
13
13
|
}],
|
|
14
|
-
[ 'OS=="mac"', {
|
|
15
|
-
'sources': ['src/osx/DeviceINQ.mm', 'src/osx/BluetoothWorker.mm', 'src/osx/pipe.c', 'src/osx/BluetoothDeviceResources.mm', 'src/osx/BluetoothSerialPort.mm', 'src/osx/BTSerialPortBinding.mm'],
|
|
16
|
-
'include_dirs' : [ "<!(node -e \"require('nan')\")", 'src', 'src/osx' ],
|
|
17
|
-
'libraries':['-framework Foundation', '-framework IOBluetooth', '-fobjc-arc'],
|
|
18
|
-
'cflags!': [ '-fno-exceptions' ],
|
|
19
|
-
'cflags_cc!': [ '-fno-exceptions' ],
|
|
20
|
-
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'OTHER_CFLAGS': [ '-Wno-unused-function' ] }
|
|
21
|
-
}],
|
|
22
14
|
[ 'OS=="win"', {
|
|
23
15
|
'sources': [ 'src/windows/BluetoothSerialPort.cc', 'src/windows/DeviceINQ.cc', 'src/windows/BTSerialPortBinding.cc', 'src/windows/BluetoothHelpers.cc' ],
|
|
24
16
|
'include_dirs' : [ "<!(node -e \"require('nan')\")", 'src', 'src/windows' ],
|
package/package.json
CHANGED
|
@@ -1,60 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"Kevin Clarens"
|
|
59
|
-
]
|
|
2
|
+
"name": "bluetooth-serial-port",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Bluetooth serial port communication for Node.js",
|
|
5
|
+
"author": "Eelco Cramer <eelco@hailendal.org>",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"bluetooth",
|
|
8
|
+
"serial port",
|
|
9
|
+
"rfcomm",
|
|
10
|
+
"linux",
|
|
11
|
+
"windows"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/eelcocramer/node-bluetooth-serial-port",
|
|
14
|
+
"bugs": "https://github.com/eelcocramer/node-bluetooth-serial-port/issues",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/eelcocramer/node-bluetooth-serial-port"
|
|
18
|
+
},
|
|
19
|
+
"directories": {
|
|
20
|
+
"lib": "./lib"
|
|
21
|
+
},
|
|
22
|
+
"main": "./lib/bluetooth-serial-port.js",
|
|
23
|
+
"types": "./lib/bluetooth-serial-port.d.ts",
|
|
24
|
+
"os": [
|
|
25
|
+
"linux",
|
|
26
|
+
"win32"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"bindings": "1.5.x",
|
|
30
|
+
"nan": "2.16.x",
|
|
31
|
+
"stable": "^0.1.8"
|
|
32
|
+
},
|
|
33
|
+
"optionalDependencies": {
|
|
34
|
+
"@types/node": "^18.0.0"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">= 16.x",
|
|
38
|
+
"npm": ">= 8.x"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"install": "node-gyp configure build",
|
|
42
|
+
"install-debug": "node-gyp configure build --debug"
|
|
43
|
+
},
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"contributors": [
|
|
46
|
+
"Eric Smekens",
|
|
47
|
+
"Juho Vepsäläinen",
|
|
48
|
+
"Elmar Langholz",
|
|
49
|
+
"Donald Ness",
|
|
50
|
+
"Joost Verdoorn",
|
|
51
|
+
"Max Metral",
|
|
52
|
+
"Thomas Wickham",
|
|
53
|
+
"Adrián Estrada",
|
|
54
|
+
"Juan Gomez",
|
|
55
|
+
"Eric Lundby",
|
|
56
|
+
"Kevin Clarens"
|
|
57
|
+
]
|
|
60
58
|
}
|
package/qemu-arm-static
ADDED
|
Binary file
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
8
8
|
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
#ifndef NODE_BTSP_SRC_SERIAL_PORT_BINDING_H
|
|
@@ -40,7 +40,7 @@ class BTSerialPortBinding : public Nan::ObjectWrap {
|
|
|
40
40
|
#endif
|
|
41
41
|
|
|
42
42
|
static Nan::Persistent<v8::FunctionTemplate> s_ct;
|
|
43
|
-
static void Init(v8::
|
|
43
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
44
44
|
static NAN_METHOD(Write);
|
|
45
45
|
static NAN_METHOD(Close);
|
|
46
46
|
static NAN_METHOD(Read);
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
class BTSerialPortBindingServer : public Nan::ObjectWrap {
|
|
24
24
|
public:
|
|
25
|
-
static void Init(v8::
|
|
25
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
26
26
|
static NAN_METHOD(Write);
|
|
27
27
|
static NAN_METHOD(Close);
|
|
28
28
|
static NAN_METHOD(Read);
|
package/src/DeviceINQ.h
CHANGED
|
@@ -46,7 +46,7 @@ class DeviceINQ : public Nan::ObjectWrap {
|
|
|
46
46
|
#ifdef _WIN32
|
|
47
47
|
__declspec(property(get = GetInitializedProperty)) bool Initialized;
|
|
48
48
|
#endif
|
|
49
|
-
static void Init(v8::
|
|
49
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
50
50
|
static void EIO_SdpSearch(uv_work_t *req);
|
|
51
51
|
static void EIO_AfterSdpSearch(uv_work_t *req);
|
|
52
52
|
#ifdef __APPLE__
|
|
@@ -79,15 +79,16 @@ void BTSerialPortBinding::EIO_AfterConnect(uv_work_t *req) {
|
|
|
79
79
|
|
|
80
80
|
Nan::TryCatch try_catch;
|
|
81
81
|
|
|
82
|
+
Nan::AsyncResource resource("bluetooth-serial-port:Connect");
|
|
82
83
|
if (baton->status == 0) {
|
|
83
|
-
baton->cb->Call(0, NULL);
|
|
84
|
+
baton->cb->Call(0, NULL, &resource);
|
|
84
85
|
} else {
|
|
85
86
|
char msg[80];
|
|
86
87
|
sprintf(msg, "Cannot connect: %d", baton->status);
|
|
87
88
|
Local<Value> argv[] = {
|
|
88
89
|
Nan::Error(msg)
|
|
89
90
|
};
|
|
90
|
-
baton->ecb->Call(1, argv);
|
|
91
|
+
baton->ecb->Call(1, argv, &resource);
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
if (try_catch.HasCaught()) {
|
|
@@ -140,7 +141,8 @@ void BTSerialPortBinding::EIO_AfterWrite(uv_work_t *req) {
|
|
|
140
141
|
argv[1] = Nan::New<v8::Integer>((int32_t)data->result);
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
Nan::AsyncResource resource("bluetooth-serial-port:Write");
|
|
145
|
+
data->callback->Call(2, argv, &resource);
|
|
144
146
|
|
|
145
147
|
uv_mutex_lock(&write_queue_mutex);
|
|
146
148
|
ngx_queue_remove(&queuedWrite->queue);
|
|
@@ -202,17 +204,15 @@ void BTSerialPortBinding::EIO_AfterRead(uv_work_t *req) {
|
|
|
202
204
|
argv[0] = Nan::Error("Error reading from connection");
|
|
203
205
|
argv[1] = Nan::Undefined();
|
|
204
206
|
} else {
|
|
205
|
-
Local<Object>
|
|
206
|
-
Local<Function> bufferConstructor = Local<Function>::Cast(globalObj->Get(Nan::New("Buffer").ToLocalChecked()));
|
|
207
|
-
Handle<Value> constructorArgs[1] = { Nan::New<v8::Integer>(baton->size) };
|
|
208
|
-
Local<Object> resultBuffer = Nan::NewInstance(bufferConstructor, 1, constructorArgs).ToLocalChecked();
|
|
207
|
+
Local<Object> resultBuffer = Nan::NewBuffer(baton->size).ToLocalChecked();
|
|
209
208
|
memcpy(Buffer::Data(resultBuffer), baton->result, baton->size);
|
|
210
209
|
|
|
211
210
|
argv[0] = Nan::Undefined();
|
|
212
211
|
argv[1] = resultBuffer;
|
|
213
212
|
}
|
|
214
213
|
|
|
215
|
-
|
|
214
|
+
Nan::AsyncResource resource("bluetooth-serial-port:Read");
|
|
215
|
+
baton->cb->Call(2, argv, &resource);
|
|
216
216
|
|
|
217
217
|
if (try_catch.HasCaught()) {
|
|
218
218
|
Nan::FatalException(try_catch);
|
|
@@ -225,7 +225,7 @@ void BTSerialPortBinding::EIO_AfterRead(uv_work_t *req) {
|
|
|
225
225
|
baton = NULL;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
void BTSerialPortBinding::Init(
|
|
228
|
+
void BTSerialPortBinding::Init(Local<Object> target) {
|
|
229
229
|
Nan::HandleScope scope;
|
|
230
230
|
|
|
231
231
|
Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(New);
|
|
@@ -233,12 +233,13 @@ void BTSerialPortBinding::Init(Handle<Object> target) {
|
|
|
233
233
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
|
234
234
|
t->SetClassName(Nan::New("BTSerialPortBinding").ToLocalChecked());
|
|
235
235
|
|
|
236
|
+
Isolate *isolate = target->GetIsolate();
|
|
237
|
+
Local<Context> ctx = isolate->GetCurrentContext();
|
|
238
|
+
|
|
236
239
|
Nan::SetPrototypeMethod(t, "write", Write);
|
|
237
240
|
Nan::SetPrototypeMethod(t, "read", Read);
|
|
238
241
|
Nan::SetPrototypeMethod(t, "close", Close);
|
|
239
|
-
|
|
240
|
-
target->Set(Nan::New("BTSerialPortBinding").ToLocalChecked(), t->GetFunction());
|
|
241
|
-
target->Set(Nan::New("BTSerialPortBinding").ToLocalChecked(), t->GetFunction());
|
|
242
|
+
Nan::Set(target, Nan::New("BTSerialPortBinding").ToLocalChecked(), t->GetFunction(ctx).ToLocalChecked());
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
BTSerialPortBinding::BTSerialPortBinding() :
|
|
@@ -258,9 +259,9 @@ NAN_METHOD(BTSerialPortBinding::New) {
|
|
|
258
259
|
return Nan::ThrowError(usage);
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
String::Utf8Value address(info[0]);
|
|
262
|
+
String::Utf8Value address(info.GetIsolate(), info[0]);
|
|
262
263
|
|
|
263
|
-
int channelID = info[1]->Int32Value();
|
|
264
|
+
int channelID = info[1]->Int32Value(Nan::GetCurrentContext()).ToChecked();
|
|
264
265
|
if (channelID <= 0) {
|
|
265
266
|
return Nan::ThrowTypeError("ChannelID should be a positive int value.");
|
|
266
267
|
}
|
|
@@ -387,8 +388,9 @@ NAN_METHOD(BTSerialPortBinding::Read) {
|
|
|
387
388
|
argv[0] = Nan::Error("The connection has been closed");
|
|
388
389
|
argv[1] = Nan::Undefined();
|
|
389
390
|
|
|
391
|
+
Nan::AsyncResource resource("bluetooth-serial-port:Read");
|
|
390
392
|
Nan::Callback *nc = new Nan::Callback(cb);
|
|
391
|
-
nc->Call(2, argv);
|
|
393
|
+
nc->Call(2, argv, &resource);
|
|
392
394
|
} else {
|
|
393
395
|
read_baton_t *baton = new read_baton_t();
|
|
394
396
|
baton->rfcomm = rfcomm;
|