addService = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "addService", [params]); }
...
### addService ###
Add a service with characteristics and descriptors. If more than one service is added, add them sequentially.
```javascript
bluetoothle.addService(success, error, params);
```
##### Params #####
* service = A service UUID.
* characteristics = An object of characteristics data as shown below.
```javascript
...
bond = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "bond", [params]); }
...
### 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
{
...
bytesToEncodedString = function (bytes) { return btoa(String.fromCharCode.apply(null, bytes)); }
...
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = The service's UUID
* characteristic = The characteristic's UUID
* value = Base64 encoded string
* type = Set to "noResponse" to enable write without response, all other values will write normally.
Value is a base64 encoded string of bytes to write. Use bluetoothle.bytesToEncodedString(bytes) to convert to base64 encoded string from a unit8Array.
To write without response, set type to "noResponse". Any other value will default to write with response. Note, no callback
will occur on write without response on iOS.
```javascript
var string = "Write Hello World";
var bytes = bluetoothle.stringToBytes(string);
var encodedString = bluetoothle.bytesToEncodedString(bytes);
//Note, this example doesn't actually work since it's read only characteristic
...
bytesToHex = function (bytes) { var string = []; for (var i = 0; i < bytes.length; i++) { string.push("0x" + ("0"+(bytes[i].toString(16))).substr(-2).toUpperCase()); } return string.join(" "); }
n/a
bytesToString = function (bytes) { return String.fromCharCode.apply(null, new Uint16Array(bytes)); }
...
##### Success #####
Value is a base64 encoded string of written bytes. Use bluetoothle.encodedStringToBytes(obj.value) to convert to a unit8Array. See
characteristic's specification and example below on how to correctly parse this.
```javascript
var returnObj = {"status":"written","service":"180F","characteristic":"2A19
","value":"V3JpdGUgSGVsbG8gV29ybGQ=","address":"ABC123"}
var bytes = bluetoothle.encodedStringToBytes(returnObj.value);
var string = bluetoothle.bytesToString(bytes); //This should equal Write Hello World
```
### writeQ ###
Write Quick / Queue, use this method to quickly execute write without response commands when writing more than 20 bytes at a time
. The data will automatically be split up into 20 bytes packets. On iOS, these packets are written immediately since iOS uses queues
. You probably won't see much of a performance increase using writeQ. On Android, a queue isn't used internally. Instead
another call shouldn't be made until onCharacteristicWrite is called. This could be done at the Javascript layer, but the
Javascript to plugin "bridge" must be crossed twice, which leads to some significant slow downs when milliseconds make
a difference. For even better write throughput, use requestConnectionPriority('high') as well. Note, no callback will
occur on write without response on iOS.
...
characteristics = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "characteristics", [params]); }
...
### characteristics ###
Discover the service's characteristics. Not providing an array of characteristics will return all characteristics and take
longer to discover. iOS support only.
```javascript
bluetoothle.characteristics(characteristicsSuccess, characteristicsError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = Service UUID
* characteristics = An array of characteristic IDs to discover or empty array / null
...
close = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "close", [params]); }
...
### close ###
Close/dispose a Bluetooth LE device. Prior to 2.7.0, you needed to disconnect to the device before closing, but this is no longer
the case.
**Starting with iOS 10, disconnecting before closing seems required!**
```javascript
bluetoothle.close(closeSuccess, closeError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
connect = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "connect", [params]); }
...
### 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().
```javascript
bluetoothle.connect(connectSuccess, connectError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* autoConnect = Automatically connect as soon as the remote device becomes available (Android)
```javascript
...
descriptors = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "descriptors", [params]); }
...
### descriptors ###
Discover the characteristic's descriptors. iOS support only.
```javascript
bluetoothle.descriptors(descriptorsSuccess, descriptorsError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = The service's ID
* characteristic = The characteristic's ID
...
disable = function (successCallback, errorCallback) { cordova.exec(successCallback, errorCallback, bluetoothleName, "disable", []); }
...
### disable ###
Disable Bluetooth on the device. Android support only.
```javascript
bluetoothle.disable(disableSuccess, disableError);
```
##### Error #####
* errorEnable = Bluetooth isn't enabled, so unable to disable.
* errorDisable = Immediate failure of the internal disable() function due to Bluetooth already off, so unable to enable. This shouldn
't occur since the plugin is already checking this condition anyways.
##### Success #####
...
disconnect = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "disconnect", [params]); }
...
### disconnect ###
Disconnect from a Bluetooth LE device. It's simpler to just call close().
**Starting with iOS 10, disconnecting before closing seems required!**
```javascript
bluetoothle.disconnect(disconnectSuccess, disconnectError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
discover = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "discover", [params]); }
...
### discover ###
Discover all the devices services, characteristics and descriptors. Doesn't need to be called again after disconnecting and
then reconnecting. If using iOS, you shouldn't use discover and services/characteristics/descriptors on the same device. There
seems to be an issue with calling discover on iOS8 devices, so use with caution. On some Android versions, the discovered services
may be cached for a device. Subsequent discover events will make use of this cache. If your device's services change, set
the clearCache parameter to force Android to re-discover services.
```javascript
bluetoothle.discover(discoverSuccess, discoverError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* clearCache = true / false (default) Force the device to re-discover services, instead of relying on cache from previous discovery
(Android only)
```javascript
...
enable = function (successCallback, errorCallback) { cordova.exec(successCallback, errorCallback, bluetoothleName, "enable", []); }
...
### enable ###
Enable Bluetooth on the device. Android support only.
```javascript
bluetoothle.enable(enableSuccess, enableError);
```
##### Error #####
* errorDisable = Bluetooth isn't disabled, so unable to enable.
* errorEnable = Immediate failure of the internal enable() function due to Bluetooth already on or airplane mode, so unable to enable
.
##### Success #####
...
encodedStringToBytes = function (string) { var data = atob(string); var bytes = new Uint8Array(data.length); for (var i = 0; i < bytes.length; i++) { bytes[i] = data.charCodeAt(i); } return bytes; }
...
##### Success #####
* status => scanStarted = Scan has started
* status => scanResult = Scan has found a device
* name = the device's display name
* address = the device's address / identifier for connecting to the object
* rssi = signal strength
* advertisement = advertisement data in encoded string of bytes, use bluetoothle.encodedStringToBytes
() (Android)
* advertisement = advertisement hash with the keys specified [here](https://developer.apple.com/library/ios/documentation/CoreBluetooth
/Reference/CBCentralManagerDelegate_Protocol/#//apple_ref/doc/constant_group/Advertisement_Data_Retrieval_Keys) (iOS)
* advertisement = empty (Windows)
```javascript
{
"status": "scanStarted"
}
...
hasPermission = function (successCallback, errorCallback) { cordova.exec(successCallback, errorCallback, bluetoothleName, "hasPermission", []); }
...
### hasPermission ###
Determine whether coarse location privileges are granted since scanning for unpaired devices requies it in Android API 23
```javascript
bluetoothle.hasPermission(hasPermissionSuccess);
```
##### Success #####
* status => hasPermission = true/false
```javascript
{
...
initialize = function (successCallback, params) { cordova.exec(successCallback, successCallback, bluetoothleName, "initialize", [params]); }
...
### initialize ###
Initialize Bluetooth on the device. Must be called before anything else. Callback will continuously be used whenever Bluetooth is
enabled or disabled. Note: Although Bluetooth initialization could initially be successful, there's no guarantee whether it
will stay enabled. Each call checks whether Bluetooth is disabled. If it becomes disabled, the user must connect to the device,
start a read/write operation, etc again. If Bluetooth is disabled, you can request the user to enable it by setting the request
property to true. The `request` property in the `params` argument is optional and defaults to false. The `restoreKey` property requires
using the Bluetooth Central background mode. This function should only be called once.
```javascript
bluetoothle.initialize(initializeResult, params);
```
##### Params #####
* request = true / false (default) - Should user be prompted to enable Bluetooth
* statusReceiver = true (default) / false - Should change in Bluetooth status notifications be sent.
* restoreKey = A unique string to identify your app. Bluetooth Central background mode is required to use this, but background mode
doesn't seem to require specifying the restoreKey.
...
initializePeripheral = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "initializePeripheral", [params]); }
...
### initializePeripheral ###
Initialize Bluetooth on the device. Must be called before anything else. Callback will continuously be used whenever Bluetooth is
enabled or disabled. Note: Although Bluetooth initialization could initially be successful, there's no guarantee whether it
will stay enabled. Each call checks whether Bluetooth is disabled. If it becomes disabled, the user must readd services, start
advertising, etc again. If Bluetooth is disabled, you can request the user to enable it by setting the request property to true.
The `request` property in the `params` argument is optional and defaults to false. The `restoreKey` property requires using the
Bluetooth Peripheral background mode. This function should only be called once.
Additionally this where new events are delivered for read, write, and subscription requests. See the success section for more details
.
```javascript
bluetoothle.initializePeripheral(success, error, params);
```
##### Params #####
* request = true / false (default) - Should user be prompted to enable Bluetooth
* restoreKey = A unique string to identify your app. Bluetooth Peripheral background mode is required to use this, but background
mode doesn't seem to require specifying the restoreKey.
```javascript
...
isAdvertising = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "isAdvertising", []); }
...
```
### isAdvertising ###
Determine if app is advertising or not.
```javascript
bluetoothle.isAdvertising(success, error);
```
##### Return #####
```javascript
{
"isAdvertising":true
...
isBonded = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "isBonded", [params]); }
...
### isBonded ###
Determine whether the device is bonded or not, or error if not initialized. Android support only.
```javascript
bluetoothle.isBonded(isBondedSuccess, isBondedError, params);
```
#### Params ####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
isConnected = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "isConnected", [params]); }
...
### isConnected ###
Determine whether the device is connected, or error if not initialized or never connected to device.
```javascript
bluetoothle.isConnected(isConnectedSuccess, isConnectedError, params);
```
#### Params ####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
isDiscovered = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "isDiscovered", [params]); }
...
### isDiscovered ###
Determine whether the device's characteristics and descriptors have been discovered, or error if not initialized or not connected
to device. Note, on Android, you can connect, discover and then disconnect. isDiscovered will return an error due to the device
not being connected. But if you call reconnect and call isDiscovered again, it will return isDiscovered => true since the
device stays discovered until calling close().
```javascript
bluetoothle.isDiscovered(isDiscoveredSuccess, isDiscoveredError, params);
```
#### Params ####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
isEnabled = function (successCallback) { cordova.exec(successCallback, successCallback, bluetoothleName, "isEnabled", []); }
...
```
### isEnabled ###
Determine whether the adapter is enabled. No error callback
```javascript
bluetoothle.isEnabled(isEnabled);
```
##### Success #####
* status => isEnabled = true/false
```javascript
{
...
isInitialized = function (successCallback) { cordova.exec(successCallback, successCallback, bluetoothleName, "isInitialized", []); }
...
### isInitialized ###
Determine whether the adapter is initialized. No error callback. Returns true or false
```javascript
bluetoothle.isInitialized(isInitialized);
```
##### Success Return #####
* status => isInitialized = true/false
```javascript
{
...
isLocationEnabled = function (successCallback, errorCallback) { cordova.exec(successCallback, errorCallback, bluetoothleName, "isLocationEnabled", []); }
...
### isLocationEnabled ###
Determine if location services are enabled or not. Location Services are required to find devices in Android API 23.
```javascript
bluetoothle.isLocationEnabled(isLocationEnabledSuccess, isLocationEnabledError);
```
##### Success #####
* status => isLocationEnabled = true/false
```javascript
{
...
isScanning = function (successCallback) { cordova.exec(successCallback, successCallback, bluetoothleName, "isScanning", []); }
...
### isScanning ###
Determine whether the adapter is initialized. No error callback. Returns true or false
```javascript
bluetoothle.isScanning(isScanning);
```
##### Return #####
* status => isScanning = true/false
```javascript
{
...
mtu = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "mtu", [params]); }
...
```
### mtu ###
Set MTU of a connected device. Android only.
```javascript
bluetoothle.mtu(mtuSuccess, mtuError, params);
```
#### Params ####
* address = The address/identifier provided by the scan's return object
* mtu - Integer value mtu should be set to
```javascript
...
notify = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "notify", [params]); }
...
```
### notify ###
Update a value for a subscription. Currently all subscribed devices will receive update. Device specific updates will be added in
the future. If ```sent``` equals false in the return value, you must wait for the ```peripheralManagerIsReadyToUpdateSubscribers
``` event before sending more updates.
```javascript
bluetoothle.notify(success, error, params);
```
##### Params #####
```javascript
var params = {
"service":"1234",
"characteristic":"ABCD",
...
read = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "read", [params]); }
...
### read ###
Read a particular service's characteristic once.
```javascript
bluetoothle.read(readSuccess, readError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = The service's UUID
* characteristic = The characteristic's UUID
...
readDescriptor = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "readDescriptor", [params]); }
...
}
UUID descriptorUuid = descriptor.getUuid();
UUID characteristicUuid = characteristic.getUuid();
AddDescriptorCallback(descriptorUuid, characteristicUuid, connection, operationRead, callbackContext);
boolean result = bluetoothGatt.readDescriptor(descriptor);
if (!result) {
JSONObject returnObj = new JSONObject();
addDevice(returnObj, device);
addDescriptor(returnObj, descriptor);
...
reconnect = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "reconnect", [params]); }
...
### reconnect ###
Reconnect to a previously connected Bluetooth device. The app should use a timer to limit the connecting time. If a timeout occurs
, the reconnection attempt should be canceled using disconnect() or close().
```javascript
bluetoothle.reconnect(reconnectSuccess, reconnectError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
removeAllServices = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "removeAllServices", [params]); }
...
```
### removeAllServices ###
Remove all services
```javascript
bluetoothle.removeAllServices(success, error);
```
##### Return #####
```javascript
{
"status":"allServicesRemoved"
}
...
removeService = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "removeService", [params]); }
...
```
### removeService ###
Remove a service.
```javascript
bluetoothle.removeService(success, error, params);
```
##### Params #####
* service = A service UUID.
```javascript
var params = {
...
requestConnectionPriority = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "requestConnectionPriority", [params]); }
...
### requestConnectionPriority ###
Request a change in the connection priority to improve throughput when transfer large amounts of data via BLE. Android support only
. iOS will return error.
```javascript
bluetoothle.requestConnectionPriority(success, error, params);
```
#### Params ####
* address = The address/identifier provided by the scan's return object
* connectionPriority = low / balanced / high
```javascript
...
requestLocation = function (successCallback, errorCallback) { cordova.exec(successCallback, errorCallback, bluetoothleName, "requestLocation", []); }
...
### requestLocation ###
Prompt location services settings pages. ```requestLocation``` property returns whether location services are enabled or disabled
. Location Services are required to find devices in Android API 23.
```javascript
bluetoothle.requestLocation(requestLocationSuccess, requestLocationError);
```
##### Success #####
* status => requestLocation = true/false
```javascript
{
...
requestPermission = function (successCallback, errorCallback) { cordova.exec(successCallback, errorCallback, bluetoothleName, "requestPermission", []); }
...
### requestPermission ###
Request coarse location privileges since scanning for unpaired devices requires it in Android API 23. Will return an error if called
on iOS or Android versions prior to 6.0.
```javascript
bluetoothle.requestPermission(requestPermissionSuccess, requestPermissionError);
```
##### Success #####
* status => requestPermission = true/false
```javascript
{
...
respond = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "respond", [params]); }
...
### respond ###
Respond to a read or write request
```javascript
bluetoothle.respond(success, error, params);
```
##### Params #####
```javascript
//This was a read
var params = {
"requestId":0,
...
retrieveConnected = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "retrieveConnected", [params]); }
...
### retrieveConnected ###
Retrieved paired Bluetooth LE devices. Yes, this function should be renamed, but I went with iOS's naming. In iOS, devices
that are "paired" to will not return during a normal scan. Callback is "instant" compared to a scan. I haven
't been able to get UUID filtering working on Android, so it returns all paired BLE devices.
```javascript
bluetoothle.retrieveConnected(retrieveConnectedSuccess, retrieveConnectedError, params
);
```
##### Params #####
* services = An array of service IDs to filter the retrieval by. If no service IDs are specified, no devices will be returned. Ignored
on Android
```javascript
{
...
rssi = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "rssi", [params]); }
...
### rssi ###
Read RSSI of a connected device. RSSI is also returned with scanning.
```javascript
bluetoothle.rssi(rssiSuccess, rssiError, params);
```
#### Params ####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
services = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "services", [params]); }
...
### services ###
Discover the device's services. Not providing an array of services will return all services and take longer to discover. iOS
support only.
```javascript
bluetoothle.services(servicesSuccess, servicesError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* services = An array of service IDs to filter the scan or empty array / null
```javascript
...
startAdvertising = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "startAdvertising", [params]); }
...
### startAdvertising ###
Start advertising as a BLE device. Note: This needs to be improved so services can be used for both Android and iOS.
On iOS, the advertising devices likes to rename itself back to the name of the device, i.e. Rand' iPhone
```javascript
bluetoothle.startAdvertising(success, error, params);
```
##### Params #####
```javascript
var params = {
"services":["1234"], //iOS
"service":"1234", //Android
...
startScan = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "startScan", [params]); }
...
### startScan ###
Scan for Bluetooth LE devices. Since scanning is expensive, stop as soon as possible. The Cordova app should use a timer to limit
the scan interval. Also, Android uses an AND operator for filtering, while iOS uses an OR operator. Android API >= 23 requires
ACCESS_COARSE_LOCATION permissions to find unpaired devices. Permissions can be requested by using the hasPermission and requestPermission
functions. Android API >= 23 also requires location services to be enabled. Use ```isLocationEnabled``` to determine whether
location services are enabled. If not enabled, use ```requestLocation``` to prompt the location services settings page.
```javascript
bluetoothle.startScan(startScanSuccess, startScanError, params);
```
##### Params #####
* services = An array of service IDs to filter the scan or empty array / null. This parameter is not supported on Windows platform
yet.
* iOS - See [iOS Docs](https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBCentralManager_Class/#//apple_ref
/doc/constant_group/Peripheral_Scanning_Options)
* allowDuplicates = True/false to allow duplicate advertisement packets, defaults to false.
* Android - See [Android Docs](http://developer.android.com/reference/android/bluetooth/le/ScanSettings.html)
...
stopAdvertising = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "stopAdvertising", [params]); }
...
```
### stopAdvertising ###
Stop advertising
```javascript
bluetoothle.stopAdvertising(success, error);
```
##### Return #####
```javascript
{
"status":"advertisingStopped"
...
stopScan = function (successCallback, errorCallback) { cordova.exec(successCallback, errorCallback, bluetoothleName, "stopScan", []); }
...
### stopScan ###
Stop scan for Bluetooth LE devices. Since scanning is expensive, stop as soon as possible. The app should use a timer to limit the
scanning time.
```javascript
bluetoothle.stopScan(stopScanSuccess, stopScanError);
```
##### Success #####
* status => scanStop = Scan has stopped
```javascript
{
...
stringToBytes = function (string) { var bytes = new ArrayBuffer(string.length * 2); var bytesUint16 = new Uint16Array(bytes); for (var i = 0; i < string.length; i++) { bytesUint16[i] = string.charCodeAt(i); } return new Uint8Array(bytesUint16); }
...
* value = Base64 encoded string
* type = Set to "noResponse" to enable write without response, all other values will write normally.
Value is a base64 encoded string of bytes to write. Use bluetoothle.bytesToEncodedString(bytes) to convert to base64 encoded string
from a unit8Array.
To write without response, set type to "noResponse". Any other value will default to write with response. Note, no callback
will occur on write without response on iOS.
```javascript
var string = "Write Hello World";
var bytes = bluetoothle.stringToBytes(string);
var encodedString = bluetoothle.bytesToEncodedString(bytes);
//Note, this example doesn't actually work since it's read only characteristic
{"value":"V3JpdGUgSGVsbG8gV29ybGQ=","service":"180F","characteristic":"2A19
","type":"noResponse","address":"ABC123"}
```
##### Success #####
...
subscribe = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "subscribe", [params]); }
...
```
### subscribe ###
Subscribe to a particular service's characteristic. Once a subscription is no longer needed, execute unsubscribe in a similar
fashion. The Client Configuration descriptor will automatically be written to enable notification/indication based on the characteristic
's properties.
```javascript
bluetoothle.subscribe(subscribeSuccess, subscribeError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = The service's UUID
* characteristic = The characteristic's UUID
...
unbond = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "unbond", [params]); }
...
### 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
{
...
unsubscribe = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "unsubscribe", [params]); }
...
### unsubscribe ###
Unsubscribe to a particular service's characteristic.
```javascript
bluetoothle.unsubscribe(unsubscribeSuccess, unsubscribeError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = The service's UUID
* characteristic = The characteristic's UUID
...
wasConnected = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "wasConnected", [params]); }
...
### wasConnected ###
Determine whether the device was connected, or error if not initialized.
```javascript
bluetoothle.wasConnected(wasConnectedSuccess, wasConnectedError, params);
```
#### Params ####
* address = The address/identifier provided by the scan's return object
```javascript
{
...
write = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "write", [params]); }
...
### write ###
Write a particular service's characteristic.
```javascript
bluetoothle.write(writeSuccess, writeError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = The service's UUID
* characteristic = The characteristic's UUID
* value = Base64 encoded string
...
writeDescriptor = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "writeDescriptor", [params]); }
...
### writeDescriptor ###
Write a particular characteristic's descriptor. Unable to write characteristic configuration directly to keep in line with
iOS implementation. Instead use subscribe/unsubscribe, which will automatically enable/disable notification.
```javascript
bluetoothle.writeDescriptor(writeDescriptorSuccess, writeDescriptorError, params);
```
##### Params #####
* address = The address/identifier provided by the scan's return object
* service = The service's ID
* characteristic = The characteristic's ID
* descriptor = The descriptor's ID
...
writeQ = function (successCallback, errorCallback, params) { cordova.exec(successCallback, errorCallback, bluetoothleName, "writeQ", [params]); }
...
Warnings
* This is experimental. Test heavily before using in any production code.
* iOS won't see much performance gain, but Android should.
* Only supports one call at a time. Don't execute back to back, use on multiple devices, or multiple characteristics.
```javascript
bluetoothle.writeQ(writeSuccess, writeError, params);
```
##### Params #####
See write() above.
##### Success #####
See write() above.
...