Skip to content

Commit 1358749

Browse files
committed
Modify bond/unbond behavior
1 parent 244ddec commit 1358749

File tree

10 files changed

+380
-128
lines changed

10 files changed

+380
-128
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.2.0 - 2016-07-09
2+
- Added ability to bond/unbond on Android
3+
14
## 4.1.0 - 2016-07-09
25
- wasConnected helper function
36
- Improved subscribe with Android. No longer need to specify whether notification or indication

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-bluetoothle",
3-
"version": "4.1.0",
3+
"version": "4.2.0",
44
"description": "Use the Bluetooth Low Energy plugin to connect your Cordova app to new Bluetooth devices like heart rate monitors, thermometers, etc...",
55
"cordova": {
66
"id": "cordova-plugin-bluetoothle",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<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">
33
<engines>
44
<engine name="cordova-plugman" version=">=5.0.0" />
55
<engine name="cordova-android" version=">=5.0.0" />

readme.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ Neither Android nor iOS support Bluetooth on emulators, so you'll need to test o
109109
* [bluetoothle.startScan] (#startscan)
110110
* [bluetoothle.stopScan] (#stopscan)
111111
* [bluetoothle.retrieveConnected] (#retrieveconnected)
112+
* [bluetoothle.bond] (#bond)
113+
* [bluetoothle.unbond] (#unbond)
112114
* [bluetoothle.connect] (#connect)
113115
* [bluetoothle.reconnect] (#reconnect)
114116
* [bluetoothle.disconnect] (#disconnect)
@@ -130,6 +132,7 @@ Neither Android nor iOS support Bluetooth on emulators, so you'll need to test o
130132
* [bluetoothle.isInitialized] (#isinitialized)
131133
* [bluetoothle.isEnabled] (#isenabled)
132134
* [bluetoothle.isScanning] (#isscanning)
135+
* [bluetoothle.isBonded] (#isbonded)
133136
* [bluetoothle.wasConnected] (#wasconnected)
134137
* [bluetoothle.isConnected] (#isconnected)
135138
* [bluetoothle.isDiscovered] (#isdiscovered)
@@ -161,6 +164,8 @@ Whenever the error callback is executed, the return object will contain the erro
161164
* disable - Bluetooth isn't disabled (Can't enabled if already disabled)
162165
* startScan - Scan couldn't be started (Is the scan already running?)
163166
* stopScan - Scan couldn't be stopped (Is the scan already stopped?)
167+
* bond - Bond couldn't be formed (Is it already bonding? Is the device Android?)
168+
* unbond - Bond couldn' be broken (Is it already unbonding? Is the device Android?)
164169
* connect - Connection attempt failed (Is the device address correct?)
165170
* reconnect - Reconnection attempt failed (Was the device ever connected?)
166171
* discover - Failed to discover device (Is the device already discovered or discovering?)
@@ -183,6 +188,7 @@ Whenever the error callback is executed, the return object will contain the erro
183188
* isNotDisconnected - Device is not disconnected (Don't call connect or reconnect while connected)
184189
* isNotConnected - Device isn't connected (Don't call discover or any read/write operations)
185190
* isDisconnected - Device is disconnected (Don't call disconnect)
191+
* isBonded - Operation is unsupported. (Is the device Android?)
186192

187193
For example:
188194
```javascript
@@ -405,6 +411,78 @@ An array of device objects:
405411

406412

407413

414+
### bond ###
415+
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.
416+
417+
```javascript
418+
bluetoothle.bond(bondSuccess, bondError, params);
419+
```
420+
421+
##### Params #####
422+
* address = The address/identifier provided by the scan's return object
423+
424+
```javascript
425+
{
426+
"address": "5A:94:4B:38:B3:FD"
427+
}
428+
```
429+
430+
##### Success #####
431+
* status => bonded = Device is bonded
432+
* status => bonding = Device is bonding
433+
* status => unbonded = Device is unbonded
434+
435+
```javascript
436+
{
437+
"name": "Hello World",
438+
"address": "5A:94:4B:38:B3:FD",
439+
"status": "bonded"
440+
}
441+
442+
{
443+
"name": "Hello World",
444+
"address": "5A:94:4B:38:B3:FD",
445+
"status": "bonding"
446+
}
447+
448+
{
449+
"name": "Hello World",
450+
"address": "5A:94:4B:38:B3:FD",
451+
"status": "unbonded"
452+
}
453+
```
454+
455+
456+
457+
### unbond ###
458+
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.
459+
460+
```javascript
461+
bluetoothle.unbond(unbondSuccess, unbondError, params);
462+
```
463+
464+
##### Params #####
465+
* address = The address/identifier provided by the scan's return object
466+
467+
```javascript
468+
{
469+
"address": "5A:94:4B:38:B3:FD"
470+
}
471+
```
472+
473+
##### Success #####
474+
* status => unbonded = Device is unbonded
475+
476+
```javascript
477+
{
478+
"name": "Hello World",
479+
"address": "5A:94:4B:38:B3:FD",
480+
"status": "unbonded"
481+
}
482+
```
483+
484+
485+
408486
### connect ###
409487
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().
410488

0 commit comments

Comments
 (0)