
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
ng-cordova-bluetoothle-randdusing
Advanced tools
AngularJS Wrapper for Phonegap / Cordova Bluetooth LE Plugin
This wraps the Bluetooth Low Energy Phonegap Plugin by Rand Dusing in AngularJS code so it can be used more easily in AngularJS mobile applications.
cordova plugin add cordova-plugin-bluetoothle
bower install git://github.com/randdusing/ng-cordova-bluetoothle.git#master
An example app has been created using the Ionic Framework to demonstrate the functionality. To install the example app, follow the steps below:
bower install git://github.com/randdusing/ng-cordova-bluetoothle.git#master
bower install js-md5
A few examples, but the example app is your best resource.
$cordovaBluetoothLE.initialize({request:true}).then(null,
function(obj) {
//Handle errors
},
function(obj) {
//Handle successes
}
);
Initialize uses the notify callback to keep track of changes in the Bluetooth state (on/off).
$cordovaBluetoothLE.startScan({services:[]}).then(null,
function(obj) {
//Handle errors
console.log(obj.message);
},
function(obj) {
if (obj.status == "scanResult")
{
//Device found
}
else if (obj.status == "scanStarted")
{
//Scan started
}
}
);
Scan uses the notify callback as well since multiple scanned devices may be returned.
$cordovaBluetoothLE.connect({address:"ABCDEFG"}).then(null,
function(obj) {
//Handle errors
console.log(obj.message);
},
function(obj) {
if (obj.status == "connected") {
//Device connected
} else {
//Device disconnected, handle this unexpected disconnect
}
}
);
Connect uses the notify callback as well since the connection state may change. See useResolve option below for resolve vs notify.
For details on each function, please visit https://github.com/randdusing/cordova-plugin-bluetoothle. A few methods require you wait for notify rather than resolve since the callback may be called multiple times: intialize, startScan, connect, reconnect, disconnect, subscribe. Enable and disable only wait for error since the "success" is returned to the initialize
Some examples are provided to help demonstrate different common scenarios. Looking for more examples? Let me know!
Example of how you could queue up three read operations.
$cordovaBluetoothLE.read(params1).then(function() { //Read 1
return $cordovaBluetoothLE.read(params2); //Read 2
}).then(function() {
return $cordovaBluetoothLE.read(params3); //Read 3
}).catch(function(err) {
console.log(err); //Catch any errors
});
AngularJS - http://www.angularjs.org
Apache Cordova - http://cordova.apache.org
The code that powers the 'build generation' is a carbon copy (with minimal changes) of Nic Raboy's ngCordovaBeacon project. As of the Fork, it was licensed under the MIT license; The Cordova Wrapper was written by myself, and my employer and I retain the copyright for that; but this project is also licensed under the MIT License.
If you want to follow more of Nic's work, his blog is located here. If you want to know more about me or Jewelbots, you can follow Jewelbots on twitter, our Ink, or me.
Rand Dusing - Primary author of the Cordova Bluetooth LE Plugin. You can contact me via: randdusing@gmail.com, Facebook, LinkedIn or Twitter.
FAQs
AngularJS Wrapper for Phonegap / Cordova Bluetooth LE Plugin
We found that ng-cordova-bluetoothle-randdusing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.