Skip to content

Commit

Permalink
Merge pull request #306 from randdusing/helixhuang-master
Browse files Browse the repository at this point in the history
Bond/Unbond
  • Loading branch information
randdusing authored Jul 10, 2016
2 parents c029ab6 + 1358749 commit 6c5f004
Show file tree
Hide file tree
Showing 10 changed files with 498 additions and 98 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.2.0 - 2016-07-09
- Added ability to bond/unbond on Android

## 4.1.0 - 2016-07-09
- wasConnected helper function
- Improved subscribe with Android. No longer need to specify whether notification or indication
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-bluetoothle",
"version": "4.1.0",
"version": "4.2.0",
"description": "Use the Bluetooth Low Energy plugin to connect your Cordova app to new Bluetooth devices like heart rate monitors, thermometers, etc...",
"cordova": {
"id": "cordova-plugin-bluetoothle",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" id="cordova-plugin-bluetoothle" version="4.1.0">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" id="cordova-plugin-bluetoothle" version="4.2.0">
<engines>
<engine name="cordova-plugman" version=">=5.0.0" />
<engine name="cordova-android" version=">=5.0.0" />
Expand Down
78 changes: 78 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ Neither Android nor iOS support Bluetooth on emulators, so you'll need to test o
* [bluetoothle.startScan] (#startscan)
* [bluetoothle.stopScan] (#stopscan)
* [bluetoothle.retrieveConnected] (#retrieveconnected)
* [bluetoothle.bond] (#bond)
* [bluetoothle.unbond] (#unbond)
* [bluetoothle.connect] (#connect)
* [bluetoothle.reconnect] (#reconnect)
* [bluetoothle.disconnect] (#disconnect)
Expand All @@ -130,6 +132,7 @@ Neither Android nor iOS support Bluetooth on emulators, so you'll need to test o
* [bluetoothle.isInitialized] (#isinitialized)
* [bluetoothle.isEnabled] (#isenabled)
* [bluetoothle.isScanning] (#isscanning)
* [bluetoothle.isBonded] (#isbonded)
* [bluetoothle.wasConnected] (#wasconnected)
* [bluetoothle.isConnected] (#isconnected)
* [bluetoothle.isDiscovered] (#isdiscovered)
Expand Down Expand Up @@ -161,6 +164,8 @@ Whenever the error callback is executed, the return object will contain the erro
* disable - Bluetooth isn't disabled (Can't enabled if already disabled)
* startScan - Scan couldn't be started (Is the scan already running?)
* stopScan - Scan couldn't be stopped (Is the scan already stopped?)
* bond - Bond couldn't be formed (Is it already bonding? Is the device Android?)
* unbond - Bond couldn' be broken (Is it already unbonding? Is the device Android?)
* connect - Connection attempt failed (Is the device address correct?)
* reconnect - Reconnection attempt failed (Was the device ever connected?)
* discover - Failed to discover device (Is the device already discovered or discovering?)
Expand All @@ -183,6 +188,7 @@ Whenever the error callback is executed, the return object will contain the erro
* isNotDisconnected - Device is not disconnected (Don't call connect or reconnect while connected)
* isNotConnected - Device isn't connected (Don't call discover or any read/write operations)
* isDisconnected - Device is disconnected (Don't call disconnect)
* isBonded - Operation is unsupported. (Is the device Android?)

For example:
```javascript
Expand Down Expand Up @@ -405,6 +411,78 @@ An array of device objects:



### bond ###
Bond with a device. The first success callback should always return with ```status == bonding```. If the bond is created, the callback will return again with ```status == bonded```. If the bonding popup is canceled or the wrong code is entered, the callback will return again with ```status == unbonded```. The device doesn't need to be connected to initiate bonding. Android support only.

```javascript
bluetoothle.bond(bondSuccess, bondError, params);
```

##### Params #####
* address = The address/identifier provided by the scan's return object

```javascript
{
"address": "5A:94:4B:38:B3:FD"
}
```

##### Success #####
* status => bonded = Device is bonded
* status => bonding = Device is bonding
* status => unbonded = Device is unbonded

```javascript
{
"name": "Hello World",
"address": "5A:94:4B:38:B3:FD",
"status": "bonded"
}

{
"name": "Hello World",
"address": "5A:94:4B:38:B3:FD",
"status": "bonding"
}

{
"name": "Hello World",
"address": "5A:94:4B:38:B3:FD",
"status": "unbonded"
}
```



### unbond ###
Unbond with a device. The success callback should always return with ```status == unbonded```. The device doesn't need to be connected to initiate bonding. Android support only.

```javascript
bluetoothle.unbond(unbondSuccess, unbondError, params);
```

##### Params #####
* address = The address/identifier provided by the scan's return object

```javascript
{
"address": "5A:94:4B:38:B3:FD"
}
```

##### Success #####
* status => unbonded = Device is unbonded

```javascript
{
"name": "Hello World",
"address": "5A:94:4B:38:B3:FD",
"status": "unbonded"
}
```



### connect ###
Connect to a Bluetooth LE device. The app should use a timer to limit the connecting time in case connecting is never successful. Once a device is connected, it may disconnect without user intervention. The original connection callback will be called again and receive an object with status => disconnected. To reconnect to the device, use the reconnect method. If a timeout occurs, the connection attempt should be canceled using disconnect(). For simplicity, I recommend just using connect() and close(), don't use reconnect() or disconnect().

Expand Down
Loading

0 comments on commit 6c5f004

Please sign in to comment.