Skip to content

Commit

Permalink
add writeQ support
Browse files Browse the repository at this point in the history
  • Loading branch information
randdusing committed Mar 23, 2016
1 parent ad46552 commit 2ffbcae
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## 3.2.0 - 2016-03-23
- Add support for writeQ

## 3.1.0 - 2016-02-23
- Add support for isLocationEnabled

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ For details on each function, please visit https://github.com/randdusing/cordova
* $cordovaBluetoothLE.subscribe(params).then(null, error, success);
* $cordovaBluetoothLE.unsubscribe(params).then(success, error);
* $cordovaBluetoothLE.write(params).then(success, error);
* $cordovaBluetoothLE.writeQ(params).then(success, error);
* $cordovaBluetoothLE.readDescriptor(params).then(success, error);
* $cordovaBluetoothLE.writeDescriptor(params).then(success, error);
* $cordovaBluetoothLE.rssi(params).then(success, error);
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ng-cordova-bluetoothle",
"main": "./dist/ng-cordova-bluetoothle.js",
"version": "3.0.0",
"main": "./ng-cordova-bluetoothle.js",
"version": "3.2.0",
"description": "AngularJS Wrapper for Phonegap / Cordova Bluetooth LE Plugin",
"authors": [
"George Stocker <http://georgestocker.com>",
Expand Down
23 changes: 23 additions & 0 deletions ng-cordova-bluetoothle.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,28 @@ angular.module('ngCordovaBluetoothLE', []).factory('$cordovaBluetoothLE', ['$q',
return q.promise;
};

var writeQ = function(params) {
var q = $q.defer();
if (window.bluetoothle === undefined) {
q.reject(errorUnsupported);
} else {
var timeout = createTimeout(params, q);

window.bluetoothle.writeQ(
function(obj) {
$timeout.cancel(timeout);
q.resolve(obj);
},
function(obj) {
$timeout.cancel(timeout);
q.reject(obj);
},
params
);
}
return q.promise;
};

var readDescriptor = function(params) {
var q = $q.defer();
if (window.bluetoothle === undefined) {
Expand Down Expand Up @@ -699,6 +721,7 @@ angular.module('ngCordovaBluetoothLE', []).factory('$cordovaBluetoothLE', ['$q',
subscribe: subscribe,
unsubscribe: unsubscribe,
write: write,
writeQ: writeQ,
readDescriptor: readDescriptor,
writeDescriptor: writeDescriptor,
rssi: rssi,
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": "ng-cordova-bluetoothle",
"version": "3.1.0",
"version": "3.2.0",
"description": "AngularJS Wrapper for Phonegap / Cordova Bluetooth LE Plugin",
"author": {
"name": "George Stocker",
Expand Down

0 comments on commit 2ffbcae

Please sign in to comment.