Skip to content

Commit

Permalink
Export connect and disconnect methods
Browse files Browse the repository at this point in the history
  • Loading branch information
evanxd committed Jun 14, 2015
1 parent 37d2fc3 commit 2d44c7d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/bluetooth_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
return arrayBuffer;
};

BluetoothHelper.prototype._connect = function() {
BluetoothHelper.prototype.connect = function() {
return bluetooth.defaultAdapter.startDiscovery().catch(() => {
// Retry to connect the BLE server if failed.
this._connect();
this.connect();
}).then(discovery => {
discovery.addEventListener('devicefound',
this._handleDevicefound.bind(this));
}).catch(() => {
// Retry to connect the BLE server if failed.
this._connect();
this.connect();
});
};

BluetoothHelper.prototype._disconnect = function() {
BluetoothHelper.prototype.disconnect = function() {
if (this._gatt) {
return this._gatt.disconnect().then(() => {
return bluetooth.defaultAdapter.stopDiscovery();
Expand All @@ -70,7 +70,7 @@
for (var key in evt.attrs) {
switch (evt.attrs[key]) {
case 'defaultAdapter':
this._connect();
this.connect();
break;
}
}
Expand Down

0 comments on commit 2d44c7d

Please sign in to comment.