Skip to content

Commit

Permalink
Merge pull request #2 from Babibubebon/fix_connect
Browse files Browse the repository at this point in the history
Fix open() of BLE Adaptor
  • Loading branch information
Babibubebon authored Feb 19, 2017
2 parents 95678f2 + f5a0ac1 commit 8274248
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/adaptors/ble.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ Adaptor.prototype.open = function open(callback) {
self._connectPeripheral(this.noblePeripheral, callback);
} else {
// connect to peripheral using noble
ble.on("discover", function(peripheral) {
var discoverCallback = function(peripheral) {
if (peripheral.id === self.uuid) {
ble.stopScanning();
ble.removeListener("discover", discoverCallback);
self._connectPeripheral(peripheral, callback);
}
});
}
ble.on("discover", discoverCallback);

if (ble.state === "poweredOn") {
ble.startScanning();
Expand Down

0 comments on commit 8274248

Please sign in to comment.