linux识别csr8510,bluetooth-hci-socket

Bluetooth HCI socket binding for Node.js

node-bluetooth-hci-socket

Bluetooth HCI socket binding for Node.js

NOTE: Currently only supports Linux and Windows.

Prerequisites

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

Compatible Bluetooth 4.0 USB Adapter's

Name

USB VID

USB PID

BCM920702 Bluetooth 4.0

0x0a5c

0x21e8

BCM20702A0 Bluetooth 4.0

0x19ff

0x0239

CSR8510 A10

0x0a12

0x0001

Asus BT-400

0x0b05

0x17cb

Intel Wireless Bluetooth

0x8087

0x07dc

Install

npm install bluetooth-hci-socket

Usage

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

Actions

Create

var bluetoothHciSocket = new BluetoothHciSocket();

Set Filter

var filter = new Buffer(14);

// ...

bluetoothHciSocket.setFilter(filter);

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 .js

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 .js

HomePage

Repository

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值