Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

$cordovaBLE improvements #1079

Merged
merged 3 commits into from
Dec 1, 2015
Merged

$cordovaBLE improvements #1079

merged 3 commits into from
Dec 1, 2015

Conversation

tomasbedrich
Copy link
Contributor

  • added startScan and stopScan methods to be able to scan until something is discovered
  • removed promises from startNotification method - it doesn't make sense there
  • fixed some other methods to be up to date with latest cordova-plugin-ble-central plugin
  • updated mocks

- renamed writeCommand to writeWithoutResponse (with backwards-compatibility in mind)
- removed promise from startNotification
- fixed scan mock to use notify instead of resolve
- changed writeCommand mock to writeWithoutResponse
- updated behavior of startNotification mock
- removed old non working methods
@tomasbedrich
Copy link
Contributor Author

Should solve #981

gortok added a commit that referenced this pull request Dec 1, 2015
@gortok gortok merged commit fab270b into ionic-team:dev-next Dec 1, 2015
@tomasbedrich tomasbedrich deleted the ble-improvements branch December 1, 2015 17:53
@keytuff
Copy link

keytuff commented Jan 19, 2016

i like to write like this:

startNotification: function (deviceID, serviceUUID, characteristicUUID) {
var q = $q.defer();
ble.startNotification(deviceID, serviceUUID, characteristicUUID, function (result) {
q.notify(result);
}, function (error) {
q.reject(error);
});
return q.promise;
}

so you can use it in notify function of pormise like $CordovaBLE.Scan().

@tomasbedrich
Copy link
Contributor Author

This way you would create a promise, which is never resolved. I think it is
not the ideal solution. If you have a specific use case, you can wrap the
call to startNotification to your code returning a promise.

On Tue, Jan 19, 2016, 02:31 keyrratuff [email protected] wrote:

i like to write like this:

startNotification: function (deviceID, serviceUUID, characteristicUUID) {
var q = $q.defer();
ble.startNotification(deviceID, serviceUUID, characteristicUUID, function
(result) {
q.notify(result);
}, function (error) {
q.reject(error);
});
return q.promise;
}

so you can use it in notify function of pormise like $CordovaBLE.Scan().


Reply to this email directly or view it on GitHub
#1079 (comment).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants