Bluetooth serial port communication for Node.js
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.
If you have any problems make sure to checkout the FAQ.
- Adds cross-platform continues integration to the repository. Thanks @mackwic.
- Re-enables windows support.
- Fixes an issue where pipes and file descriptors are leaked when a connection could not be established.
- Fixes issues compile issues on OS X and Linux when using newer versions of nan.
PLEASE NOTE This release is not yet available for the Windows platform because the compilation needs to be verified first. As there are no major functional changes this release and the release, hopefully, will fix major issues on OSX I decided to go forward without Windows support for the moment. This will hopefully be fixed in the next release. I will update as soon as possible.
- Fixes an issue on OSX where multiple reads would result into a corrupted read buffer.
- Improves the implementation of the Bluetooth worker on OSX.
- Better performance while writing to the Bluetooth connection on OSX.
- Keeps the [reader loop from reading from a closed connection]((https://github.com/eelcocramer/node-bluetooth-serial-port/issues/47).
- Will work on both node v0.8.x, v0.10.x and node v0.11.x on OSX and Linux (Windows to be done).
- When trying to write to closed connection the
writefunction will not throw an exception anymore but will call the callback as per documentation.
- Adds a
closedevent that fires when a connection is closed either by the user or remotely.
- Fixes an compile issue on Windows.
- Fixes segfault that occurs when a buffer is invalidated by the garbage collector.
- Adds experimental support for listing paired devices.
- Updates the documentation to reflect the changes made in version 1.1.0.
- Fixes typo in readme.
- Fixes buffer overflow on close() in Mac OSX.
- Adds failure callback that is called when no channel can be found.
- Fixes an issue on Mac OSX where a write action would fail when the MTU was exceeded.
- Fixes an issue on Mac OSX where data would not be written asynchronously.
- Updates the code example in the README.
win32to the supported OS'es in the
- Added windows support.
- Fixes an issue on Linux where reading from a closed or reset connection would result into a SEGFAULT.
- Updates the documentation.
- Fixes an issue where memory is freed incorrectly after closing a connection on OS X.
- Improves the timeout mechanism that is used for getting the Bluetooth service records on a remote device on OS X.
- No code changes, only updates the documentation.
- Makes the write function asynchrone.
- Takes a Buffer as the input for the write function in favor of a String.
- Reads data into a Buffer object instead of using a String.
- Improves error handling when calling the native addon.
- Fixes issue where calling
closeon a connection would result in an
Abort trap: 6error on OS X.
- Experimental support for OS X!
findSerialPortChanneldoes not invoke callback anymore when no channel was found.
foundevent now emits the Bluetooth address as the value of the name parameter
namewhen the name of the device could not be determined (used to be
- Needs Bluetooth development packages to build
apt-get install build-essential libbluetooth-dev
- Needs XCode and XCode command line tools installed.
- Needs Visual Studio (Visual C++) and its command line tools installed.
- Needs Python 2.x installed and accessible from the command line path.
npm install bluetooth-serial-port
var btSerial = new require'bluetooth-serial-port'BluetoothSerialPort;btSerialon'found'btSerialfindSerialPortChanneladdressbtSerialconnectaddress channelconsole.log'connected';btSerialwrite'my data' 'utf-8'if err console.logerr;;btSerialon'data'console.logbuffertoString'utf-8';;console.log'cannot connect';;// close the connection when you're readybtSerialclose;console.log'found nothing';;;btSerialinquire;
Emitted when data is read from the serial port connection.
- buffer - the data that was read into a Buffer object.
Emitted when a connection was closed either by the user (i.e. calling
close or remotely).
Emitted when reading from the serial port connection results in an error. The connection is closed.
- err - an Error object describing the failure.
Emitted when a bluetooth device was found.
- address - the address of the device
- name - the name of the device (or the address if the name is unavailable)
Emitted when the device inquiry execution did finish.
Starts searching for bluetooth devices. When a device is found a 'found' event will be emitted.
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.
- 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.
- [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.
Closes the connection.
Check whether the connection is open or not.
Writes a Buffer to the serial port connection.
- buffer - the Buffer to be written.
- callback(err, bytesWritten) - is called when the write action has been completed. When the
errparameter is set an error has occured, in that case
erris an Error object. When
erris not set the write action was successful and
bytesWrittencontains the amount of bytes that is written to the connection.
ONLY ON OSX
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 for more information on the