bluetooth-serial-port
Advanced tools
Comparing version 2.2.7 to 3.0.0
114
package.json
{ | ||
"name": "bluetooth-serial-port", | ||
"version": "2.2.7", | ||
"description": "Bluetooth serial port communication for Node.js", | ||
"author": "Eelco Cramer <eelco@hailendal.org>", | ||
"keywords": [ | ||
"bluetooth", | ||
"serial port", | ||
"rfcomm", | ||
"linux", | ||
"os x", | ||
"windows" | ||
], | ||
"homepage": "https://github.com/eelcocramer/node-bluetooth-serial-port", | ||
"bugs": "https://github.com/eelcocramer/node-bluetooth-serial-port/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/eelcocramer/node-bluetooth-serial-port" | ||
}, | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"main": "./lib/bluetooth-serial-port.js", | ||
"types": "./lib/bluetooth-serial-port.d.ts", | ||
"os": [ | ||
"darwin", | ||
"linux", | ||
"win32" | ||
], | ||
"dependencies": { | ||
"bindings": "1.2.x", | ||
"nan": "latest", | ||
"stable": "^0.1.8" | ||
}, | ||
"optionalDependencies": { | ||
"@types/node": "^7.0.10" | ||
}, | ||
"engines": { | ||
"node": ">= 6.x", | ||
"npm": ">= 1.1.x" | ||
}, | ||
"scripts": { | ||
"install": "node-gyp configure build", | ||
"install-debug": "node-gyp configure build --debug" | ||
}, | ||
"license": "MIT", | ||
"contributors": [ | ||
"Eric Smekens", | ||
"Juho Vepsäläinen", | ||
"Elmar Langholz", | ||
"Donald Ness", | ||
"Joost Verdoorn", | ||
"Max Metral", | ||
"Thomas Wickham", | ||
"Adrián Estrada", | ||
"Juan Gomez", | ||
"Eric Lundby", | ||
"Kevin Clarens" | ||
] | ||
"name": "bluetooth-serial-port", | ||
"version": "3.0.0", | ||
"description": "Bluetooth serial port communication for Node.js", | ||
"author": "Eelco Cramer <eelco@hailendal.org>", | ||
"keywords": [ | ||
"bluetooth", | ||
"serial port", | ||
"rfcomm", | ||
"linux", | ||
"windows" | ||
], | ||
"homepage": "https://github.com/eelcocramer/node-bluetooth-serial-port", | ||
"bugs": "https://github.com/eelcocramer/node-bluetooth-serial-port/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/eelcocramer/node-bluetooth-serial-port" | ||
}, | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"main": "./lib/bluetooth-serial-port.js", | ||
"types": "./lib/bluetooth-serial-port.d.ts", | ||
"os": [ | ||
"linux", | ||
"win32" | ||
], | ||
"dependencies": { | ||
"bindings": "1.5.x", | ||
"nan": "2.16.x", | ||
"stable": "^0.1.8" | ||
}, | ||
"optionalDependencies": { | ||
"@types/node": "^18.0.0" | ||
}, | ||
"engines": { | ||
"node": ">= 16.x", | ||
"npm": ">= 8.x" | ||
}, | ||
"scripts": { | ||
"install": "node-gyp configure build", | ||
"install-debug": "node-gyp configure build --debug" | ||
}, | ||
"license": "MIT", | ||
"contributors": [ | ||
"Eric Smekens", | ||
"Juho Vepsäläinen", | ||
"Elmar Langholz", | ||
"Donald Ness", | ||
"Joost Verdoorn", | ||
"Max Metral", | ||
"Thomas Wickham", | ||
"Adrián Estrada", | ||
"Juan Gomez", | ||
"Eric Lundby", | ||
"Kevin Clarens" | ||
] | ||
} |
161
README.md
# Bluetooth serial port communication for Node.js | ||
[![Build Status](https://travis-ci.org/eelcocramer/node-bluetooth-serial-port.svg)](https://travis-ci.org/eelcocramer/node-bluetooth-serial-port) | ||
> 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. | ||
> _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! | ||
[![Build status](https://dl.circleci.com/status-badge/img/gh/eelcocramer/node-bluetooth-serial-port/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/eelcocramer/node-bluetooth-serial-port/tree/master) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/4p1r3ddoid98qc7k?svg=true)](https://ci.appveyor.com/project/eelcocramer/node-bluetooth-serial-port) | ||
This node module lets you communicate over Bluetooth serial port with devices using Node.js. The goal is have an easy to use API. This module is great for communicating with Bluetooth enabled Arduino devices. | ||
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. | ||
@@ -12,3 +16,3 @@ If you have any problems make sure to [checkout the FAQ](https://github.com/eelcocramer/node-bluetooth-serial-port/issues?q=label%3AFAQ). | ||
* Changes node version to `lts` in the Dockerfile | ||
- Changes node version to `lts` in the Dockerfile | ||
@@ -19,3 +23,3 @@ Check the [release notes](RELEASE_NOTES.md) for an overview of the change history. | ||
* Needs Bluetooth development packages to build | ||
- Needs Bluetooth development packages to build | ||
@@ -25,4 +29,5 @@ `apt-get install build-essential libbluetooth-dev` | ||
### Note on RFCOMM Server Sockets | ||
As the initial implementation of the RFCOMM server sockets is based on BlueZ4, in order to work with SDP we need to change the bluetoothd service configuration file by modifing the systemd unit file: bluetooth.service: | ||
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: | ||
(Debian based distro) | ||
@@ -47,10 +52,6 @@ | ||
## Prerequisites on macOS | ||
* Needs Xcode and Xcode command line tools installed. | ||
## Prerequisites on Windows | ||
* Needs Visual Studio (Visual C++) and its command line tools installed. | ||
* Needs Python 2.x installed and accessible from the command line path. | ||
- Needs Visual Studio (Visual C++) and its command line tools installed. | ||
- Needs Python 2.x installed and accessible from the command line path. | ||
@@ -70,30 +71,40 @@ ## Install | ||
```javascript | ||
var btSerial = new (require("bluetooth-serial-port").BluetoothSerialPort)(); | ||
var btSerial = new (require('bluetooth-serial-port')).BluetoothSerialPort(); | ||
btSerial.on("found", function (address, name) { | ||
btSerial.findSerialPortChannel( | ||
address, | ||
function (channel) { | ||
btSerial.connect( | ||
address, | ||
channel, | ||
function () { | ||
console.log("connected"); | ||
btSerial.on('found', function(address, name) { | ||
btSerial.findSerialPortChannel(address, function(channel) { | ||
btSerial.connect(address, channel, function() { | ||
console.log('connected'); | ||
btSerial.write( | ||
Buffer.from("my data", "utf-8"), | ||
function (err, bytesWritten) { | ||
if (err) console.log(err); | ||
} | ||
); | ||
btSerial.write(Buffer.from('my data', 'utf-8'), function(err, bytesWritten) { | ||
if (err) console.log(err); | ||
}); | ||
btSerial.on("data", function (buffer) { | ||
console.log(buffer.toString("utf-8")); | ||
}); | ||
}, | ||
function () { | ||
console.log("cannot connect"); | ||
} | ||
); | ||
btSerial.on('data', function(buffer) { | ||
console.log(buffer.toString('utf-8')); | ||
}); | ||
}, function () { | ||
console.log('cannot connect'); | ||
}); | ||
// close the connection when you're ready | ||
btSerial.close(); | ||
}, function() { | ||
console.log('found nothing'); | ||
}); | ||
// close the connection when you're ready | ||
btSerial.close(); | ||
}, | ||
function () { | ||
console.log("found nothing"); | ||
} | ||
); | ||
}); | ||
btSerial.inquire(); | ||
``` | ||
@@ -104,18 +115,18 @@ | ||
```javascript | ||
var server = new(require('bluetooth-serial-port')).BluetoothSerialPortServer(); | ||
var server = new (require("bluetooth-serial-port").BluetoothSerialPortServer)(); | ||
var CHANNEL = 10; // My service channel. Defaults to 1 if omitted. | ||
var UUID = '38e851bc-7144-44b4-9cd8-80549c6f2912'; // My own service UUID. Defaults to '1101' if omitted | ||
var UUID = "38e851bc-7144-44b4-9cd8-80549c6f2912"; // My own service UUID. Defaults to '1101' if omitted | ||
server.on('data', function(buffer) { | ||
console.log('Received data from client: ' + buffer); | ||
server.on("data", function (buffer) { | ||
console.log("Received data from client: " + buffer); | ||
// ... | ||
console.log('Sending data to the client'); | ||
server.write(Buffer.from('...'), function (err, bytesWritten) { | ||
console.log("Sending data to the client"); | ||
server.write(Buffer.from("..."), function (err, bytesWritten) { | ||
if (err) { | ||
console.log('Error!'); | ||
console.log("Error!"); | ||
} else { | ||
console.log('Send ' + bytesWritten + ' to the client!'); | ||
console.log("Send " + bytesWritten + " to the client!"); | ||
} | ||
@@ -125,7 +136,11 @@ }); | ||
server.listen(function (clientAddress) { | ||
console.log('Client: ' + clientAddress + ' connected!'); | ||
}, function(error){ | ||
console.error("Something wrong happened!:" + error); | ||
}, {uuid: UUID, channel: CHANNEL} ); | ||
server.listen( | ||
function (clientAddress) { | ||
console.log("Client: " + clientAddress + " connected!"); | ||
}, | ||
function (error) { | ||
console.error("Something wrong happened!:" + error); | ||
}, | ||
{ uuid: UUID, channel: CHANNEL } | ||
); | ||
``` | ||
@@ -141,3 +156,3 @@ | ||
* buffer - the data that was read into a [Buffer](http://nodejs.org/api/buffer.html) object. | ||
- buffer - the data that was read into a [Buffer](http://nodejs.org/api/buffer.html) object. | ||
@@ -152,3 +167,3 @@ #### Event: ('closed') | ||
* err - an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object) describing the failure. | ||
- err - an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object) describing the failure. | ||
@@ -159,4 +174,4 @@ #### Event: ('found', address, name) | ||
* address - the address of the device | ||
* name - the name of the device (or the address if the name is unavailable) | ||
- address - the address of the device | ||
- name - the name of the device (or the address if the name is unavailable) | ||
@@ -179,10 +194,10 @@ #### Event: ('finished') | ||
* callback(channel) - called when finished looking for a serial port on the device. | ||
* errorCallback - called the search finished but no serial port channel was found on the device. | ||
Connects to a remote bluetooth device. | ||
- callback(channel) - called when finished looking for a serial port on the device. | ||
- errorCallback - called the search finished but no serial port channel was found on the device. | ||
Connects to a remote bluetooth device. | ||
* bluetoothAddress - the address of the remote Bluetooth device. | ||
* channel - the channel to connect to. | ||
* [successCallback] - called when a connection has been established. | ||
* [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). | ||
- bluetoothAddress - the address of the remote Bluetooth device. | ||
- channel - the channel to connect to. | ||
- [successCallback] - called when a connection has been established. | ||
- [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). | ||
@@ -201,12 +216,12 @@ #### BluetoothSerialPort.close() | ||
* buffer - the [Buffer](http://nodejs.org/api/buffer.html) to be written. | ||
* 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. | ||
- buffer - the [Buffer](http://nodejs.org/api/buffer.html) to be written. | ||
- 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. | ||
#### BluetoothSerialPort.listPairedDevices(callback) | ||
__NOT AVAILABLE ON LINUX__ | ||
**NOT AVAILABLE ON LINUX** | ||
Lists the devices that are currently paired with the host. | ||
* 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. | ||
- 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. | ||
@@ -219,14 +234,12 @@ ### BluetoothSerialPortServer | ||
* callback(address) - is called when a new client is connecting. | ||
* errorCallback(err) - is called when an error occurs. | ||
* options - An object with these properties: | ||
* 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. | ||
* channel - [Number] The RFCOMM channel the server is listening on, in the range of 1-30. If omitted the default value will be 1. | ||
- callback(address) - is called when a new client is connecting. | ||
- errorCallback(err) - is called when an error occurs. | ||
- options - An object with these properties: | ||
Example: | ||
`var options = { | ||
uuid: 'ffffffff-ffff-ffff-ffff-fffffffffff1', | ||
channel: 10 | ||
}` | ||
- 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. | ||
- channel - [Number] The RFCOMM channel the server is listening on, in the range of 1-30. If omitted the default value will be 1. | ||
Example: | ||
`var options = { uuid: 'ffffffff-ffff-ffff-ffff-fffffffffff1', channel: 10 }` | ||
#### BluetoothSerialPortServer.write(buffer, callback) | ||
@@ -236,4 +249,4 @@ | ||
* buffer - the buffer to send over the connection. | ||
* 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. | ||
- buffer - the buffer to send over the connection. | ||
- 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. | ||
@@ -256,3 +269,3 @@ #### BluetoothSerialPortServer.close() | ||
* buffer - the data that was read into a [Buffer](http://nodejs.org/api/buffer.html) object. | ||
- buffer - the data that was read into a [Buffer](http://nodejs.org/api/buffer.html) object. | ||
@@ -271,3 +284,3 @@ #### Event: ('disconnected') | ||
* err - an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object) describing the failure. | ||
- err - an [Error object](http://docs.nodejitsu.com/articles/errors/what-is-the-error-object) describing the failure. | ||
@@ -274,0 +287,0 @@ ## Typescript support |
## RELEASE NOTES | ||
### 3.0.0 | ||
* Fixes building issues with recent version of NodeJS. | ||
* Drops support for Darwin / MacOS for the moment. If you want to use the module on a Mac please install v2.2.7. | ||
### 2.2.7 | ||
@@ -4,0 +9,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4243648
65
299
+ Added@types/node@18.19.64(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addednan@2.16.0(transitive)
+ Addedundici-types@5.26.5(transitive)
- Removed@types/node@7.10.14(transitive)
- Removedbindings@1.2.1(transitive)
- Removednan@2.22.0(transitive)
Updatedbindings@1.5.x
Updatednan@2.16.x