Socket
Socket
Sign inDemoInstall

bluetooth-hci-socket

Package Overview
Dependencies
16
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

lib/native.js

20

index.js

@@ -1,15 +0,11 @@

var events = require('events');
var os = require('os');
var binding = require('./build/Release/binding.node');
var BluetoothHciSocket = binding.BluetoothHciSocket;
var platform = os.platform();
inherits(BluetoothHciSocket, events.EventEmitter);
// extend prototype
function inherits(target, source) {
for (var k in source.prototype) {
target.prototype[k] = source.prototype[k];
}
if (process.env.BLUETOOTH_HCI_SOCKET_FORCE_USB || platform === 'win32') {
module.exports = require('./lib/usb.js');
} else if (platform === 'linux') {
module.exports = require('./lib/native');
} else {
throw new Error('Unsupported platform');
}
module.exports = BluetoothHciSocket;

17

package.json
{
"name": "bluetooth-hci-socket",
"version": "0.2.0",
"version": "0.3.0",
"description": "Bluetooth HCI socket binding for Node.js",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jshint lib/*.js"
},

@@ -16,3 +16,4 @@ "repository": {

"Bluetooth",
"Linux"
"Linux",
"Windows"
],

@@ -26,7 +27,15 @@ "author": "Sandeep Mistry <sandeep.mistry@gmail.com>",

"os": [
"linux"
"linux",
"win32"
],
"dependencies": {
"debug": "^2.2.0",
"nan": "^1.8.4"
},
"optionalDependencies": {
"usb": "^1.0.6"
},
"devDependencies": {
"jshint": "^2.8.0"
}
}

@@ -5,4 +5,25 @@ # node-bluetooth-hci-socket

__NOTE:__ Currently only supports __Linux__.
__NOTE:__ Currently only supports __Linux__ and __Windows__.
## Prerequisites
### Linux
* Bluetooth 4.0 Adapter
### 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](https://msdn.microsoft.com/en-ca/library/windows/hardware/ff540196(v=vs.85).aspx) driver is required, use [Zadig tool](http://zadig.akeo.ie) to replace the driver for your adapter.
__WARNING:__ This will make the adapter unavaible in Windows Bluetooth settings!
#### Compatible Bluetooth 4.0 USB Adapter's
| Name | USB VID | USB PID |
|:---- | :------ | :-------|
| BCM920702 Bluetooth 4.0 | 0x0a5c | 0x21e8 |
| CSR8510 A10 | 0x0a12 | 0x0001 |
## Install

@@ -54,3 +75,3 @@

Query the device state. __Note:__ must be called after ```bindRaw```.
Query the device state.

@@ -61,2 +82,4 @@ ```

__Note:__ must be called after ```bindRaw```.
#### Start/stop

@@ -74,2 +97,4 @@

__Note:__ must be called after ```bindRaw``` or ```bindControl```.
#### Write

@@ -86,2 +111,4 @@

__Note:__ must be called after ```bindRaw``` or ```bindControl```.
### Events

@@ -112,1 +139,19 @@

See [examples folder](https://github.com/sandeepmistry/node-bluetooth-hci-socket/blob/master/examples) for code examples.
## Platform Notes
### Linux
#### Force Raw USB mode
Unload ```btusb``` kernel module:
```sh
sudo rmmod btusb
```
Set ```BLUETOOTH_HCI_SOCKET_FORCE_USB``` environment variable:
```sh
sudo BLUETOOTH_HCI_SOCKET_FORCE_USB=1 node <file>.js
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc