npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@switchbot/bluetooth-hci-socket

v0.5.3-10

Published

Bluetooth HCI socket binding for Node.js

Downloads

1

Readme

node-bluetooth-hci-socket

GitHub forks license NPM Fediverse IRC Channel

Bluetooth HCI socket binding for Node.js

NOTE: Currently only supports Linux, FreeBSD and Windows.

Prerequisites

NOTE: node-gyp is only required if the npm cannot find binary for your OS version otherwise the binaries are prebuilt.

Linux

  • Bluetooth 4.0 Adapter

Note: the node-usb dependency might fail install, this is ok, because it is an optional optional dependency. Installing libudev-dev via your Linux distribution's package manager will resolve the problem.

Windows

This library needs raw USB access to a Bluetooth 4.0 USB adapter, as it needs to bypass the Windows Bluetooth stack.

A WinUSB driver is required, use Zadig tool to replace the driver for your adapter.

WARNING: This will make the adapter unavailable in Windows Bluetooth settings! To roll back to the original driver go to: Device Manager -> Open Device -> Update Driver Note:

  • that one should select "Delete the driver software for this device" as per Zadig instructions if the generation of the system restoral point by Zadig fails if one wishes to use restore system restoral point as an option.

Compatible Bluetooth 4.0 USB Adapter's

| Name | USB VID | USB PID | |:---- | :------ | :-------| | BCM920702 Bluetooth 4.0 | 0x0a5c | 0x21e8 | | BCM920702 Bluetooth 4.0 | 0x0a5c | 0x21f1 | | BCM20702A0 Bluetooth 4.0 | 0x19ff | 0x0239 | | BCM20702A0 Bluetooth 4.0 | 0x0489 | 0xe07a | | BCM20702A0 Bluetooth 4.0 | 0x413c | 0x8143 | | CSR8510 A10 | 0x0a12 | 0x0001 | | Asus BT-400 | 0x0b05 | 0x17cb | | Intel Wireless Bluetooth 6235 | 0x8087 | 0x07da | | Intel Wireless Bluetooth 7260 | 0x8087 | 0x07dc | | Intel Wireless Bluetooth 7265 | 0x8087 | 0x0a2a | | Intel Wireless Bluetooth 8265 | 0x8087 | 0x0a2b | | Belkin BCM20702A0 | 0x050D | 0x065A | | Dell Precision 5530| 0x8087 | 0x0025 |

Compatible Bluetooth 4.1 USB Adapter's

| Name | USB VID | USB PID | |:---- | :------ | :-------| | BCM2045A0 Bluetooth 4.1 | 0x0a5c | 0x6412 | | Marvell AVASTAR | 0x1286 | 0x204C |

Install

npm install @abandonware/bluetooth-hci-socket

Usage

var BluetoothHciSocket = require('@abandonware/bluetooth-hci-socket');

Actions

Create

var bluetoothHciSocket = new BluetoothHciSocket();

Set Filter

var filter = new Buffer(14);

// ...

bluetoothHciSocket.setFilter(filter);

Note: setFilter is not required if bindRaw is used.

Bind

Raw Channel
bluetoothHciSocket.bindRaw([deviceId]); // optional deviceId (integer)
User Channel
bluetoothHciSocket.bindUser([deviceId]); // optional deviceId (integer)

Requires the device to be in the powered down state (sudo hciconfig hciX down).

Control Channel
bluetoothHciSocket.bindControl();

Is Device Up

Query the device state.

var isDevUp = bluetoothHciSocket.isDevUp(); // returns: true or false

Note: must be called after bindRaw.

Start/stop

Start or stop event handling:

bluetoothHciSocket.start();

// ...

bluetoothHciSocket.stop();

Note: must be called after bindRaw or bindControl.

Write

var data = new Buffer(/* ... */);

// ...


bluetoothHciSocket.write(data);

Note: must be called after bindRaw or bindControl.

Events

Data

bluetoothHciSocket.on('data', function(data) {
  // data is a Buffer

  // ...
});

Error

bluetoothHciSocket.on('error', function(error) {
  // error is a Error

  // ...
});

Examples

See examples folder for code examples.

Platform Notes

Linux

Force Raw USB mode

Unload btusb kernel module:

sudo rmmod btusb

Set BLUETOOTH_HCI_SOCKET_FORCE_USB environment variable:

sudo BLUETOOTH_HCI_SOCKET_FORCE_USB=1 node <file>.js

FreeBSD

Disable automatic loading of the default Bluetooth stack by putting no-ubt.conf into /usr/local/etc/devd/no-ubt.conf and restarting devd (sudo service devd restart).

Unload ng_ubt kernel module if already loaded:

sudo kldunload ng_ubt

OS X

Disable CSR USB Driver

sudo kextunload -b com.apple.iokit.CSRBluetoothHostControllerUSBTransport

Disable Broadcom USB Driver

sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

Windows

Force adapter USB VID and PID

Set BLUETOOTH_HCI_SOCKET_USB_VID and BLUETOOTH_HCI_SOCKET_USB_PID environment variables.

Example for USB device id: 050d:065a:

set BLUETOOTH_HCI_SOCKET_USB_VID=0x050d
set BLUETOOTH_HCI_SOCKET_USB_PID=0x065a

node <file>.js