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.
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.
writefunction will not throw an exception anymore but will call the callback as per documentation.
closedevent that fires when a connection is closed either by the user or remotely.
win32to the supported OS'es in the
closeon a connection would result in an
Abort trap: 6error on 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
apt-get install build-essential libbluetooth-dev
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.
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.
Emitted when a bluetooth device was found.
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.
Connects to a remote bluetooth device.
Closes the connection.
Check whether the connection is open or not.
Writes a Buffer to the serial port connection.
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.