Socket
Book a DemoInstallSign in
Socket

bluetooth-classic-serialport-client

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluetooth-classic-serialport-client

Bluetooth classic serial port client for Node.js

latest
Source
npmnpm
Version
0.1.25
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

Bluetooth classic serial port client for Node.js

Build status Build Status

A small Node.js library to :

  • List bluetooth paired devices (Windows only)
  • Scan nearby bluetooth devices (Linux only)
  • Connect/Disconnect to Bluetooth device using RFCOMM
  • Read/Write data

Currently using Nan as Native Addon (https://github.com/nodejs/nan).

Binaries are available here

  • Windows (32 and 64 bits)
  • Linux (64 bits)

Basic examples

Scan nearby bluetooth devices (only Linux)

Scanning process will last at most 25 seconds

const serial = new BluetoothClassicSerialportClient()

serial.scan()
  .then((devices) => console.log('Scanned devices', devices))
  .catch((err) => console.log('Error', err))

List paired bluetooth devices (only Windows)

const serial = new BluetoothClassicSerialportClient()

serial.listPairedDevices()
  .then((devices) => console.log('Paired devices', devices))
  .catch((err) => console.log('Error', err))

Connect to bluetooth device

const serial = new BluetoothClassicSerialportClient()

serial.connect(myBluetoothDevice.address)
  .then(() => console.log('Connected'))
  .catch((err) => console.log('Error', err))

Check bluetooth device is connected

const serial = new BluetoothClassicSerialportClient()

bool isConnected = serial.isOpen

Connect to bluetooth device

const serial = new BluetoothClassicSerialportClient()

  serial.connect(myBluetoothDevice.address)
  .then(() => console.log('Connected'))
  .catch((err) => console.log('Error', err))

Write to a connected bluetooth device

const serial = new BluetoothClassicSerialportClient()

serial.write('whatever-you-want')
  .then(() => console.log('Data successfully written'))
  .catch((err) => console.log('Error', err)

Read from a connected bluetooth device

const serial = new BluetoothClassicSerialportClient()

serial.on('data', (data) => console.log(data))

Close connection

const serial = new BluetoothClassicSerialportClient()

serial.close()
  .then(() => console.log('Connection successfully closed'))
  .catch((err) => console.log('Error', err))

Keywords

bluetooth

FAQs

Package last updated on 13 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts