Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Add instructions for Windows with WinUSB and Windows with Node.js Chakra #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ env:

rules:
camelcase: [2, {properties: "always"}]
comma-dangle: "always-multiline"
comma-dangle: 0
comma-spacing: [2, {before: false, after: true}]
comma-style: [2, "last"]
handle-callback-err: [2, "^.*(e|E)rr" ]
Expand Down
15 changes: 13 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,20 @@ peripheral discovered (f3f26d557108 with address <f3:f2:6d:55:71:08, random>, co

In the above output, the device address is `f3f26d557108` (or alternately `f3:f2:6d:55:71:08`). Use this value to connect to your BB-8 or Ollie.

### Windows
### Windows 8.1+ with WinUSB

To connect to your BB-8 or Ollie, you will need to be running Windows 8.1+. Follow [these instructions](https://github.com/sandeepmistry/noble#windows). Note that only [4 Blueooth adapters](https://github.com/sandeepmistry/node-bluetooth-hci-socket#compatible-bluetooth-40-usb-adapters) are compatible and that you will not be able to use your adapter through Windows and through Node.js at the same time.

### Windows 10 with Node.js Chakra

If you are running Windows 10 with the November 2015 update, you may install a version of Node.js which executes on top of the Microsoft Chakra JS engine, and has access to the Windows native Bluetooth stack.

To connect to your BB-8 or Ollie, you will need to be running Windows 8.1+. Instructions coming soon...
- Follow the instructions [here](https://github.com/hgwood/winble#install-all-the-things) to install Node.js Chakra, along with [winble](https://github.com/hgwood/winble), a Windows plugin for noble, and noble itself. Noble 1.4 or newer is required.
- Pair your device with Windows as normal (Start Menu > Settings > Devices > Bluetooth) (this might be already done)
- Hit Windows+X, select Device Manager > Bluetooth > double-click on your device name > Details > select "Bluetooth device address" and copy the address
- Use the code snippet from the Usage section with the address
- Add a second parameter to the `sphero` function like so: `sphero('<address>', {nobleBindings: require('winble')})`
- Run the code using the Node.js Chakra command prompt

## Connecting to Sphero/SPRK

Expand Down
6 changes: 4 additions & 2 deletions lib/adaptors/ble.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ var util = require("util"),

var ble;

function initBLE() {
function initBLE(options) {
var isChrome = typeof chrome !== "undefined";

// thanks to https://github.com/jgautier/firmata/blob/master/lib/firmata.js
try {
if (isChrome) {
// browser BLE interface here...
console.error("Browser-based BLE interface is not yet supported.");
} else if (options.nobleBindings) {
ble = require("noble/with-bindings")(options.nobleBindings);
} else {
ble = require("noble");
}
Expand Down Expand Up @@ -49,7 +51,7 @@ var Adaptor = module.exports = function Adaptor(peripheralId, options) {
if (this.noblePeripheral) {
ble = this.noblePeripheral._noble;
} else {
initBLE();
initBLE(opts);
}
this.peripheral = null;
this.connectedPeripherals = {};
Expand Down