mmmm
mmmm

Reputation: 3938

Using bluetooth in AngularJS

I've been trying to develope some mobile app and I'm thinking of picking up AngularJS+ZeptoJS.

But there is one problem - I couldn't find anything about accessing the bluetooth actions with Angular. I've looked through some tutorials but haven't find a single word about it. I've been thinking if it is even possible?

I mean - accessing bluetooth in mobile-app ( created in angularjs, converted in phonegap ). Not mobile-web.

I'm quite new with mobile app programming so please don't hurt me :)

And also a little bit desperate to get the answer..

Upvotes: 2

Views: 4472

Answers (1)

Brian Genisio
Brian Genisio

Reputation: 48157

It looks like there is a PhoneGap plugin for accessing Bluetooth:

https://build.phonegap.com/plugins/23

Once you get the plugin installed, you can access it via Angular. I recommend creating a service for interacting with it. It will go a little something like this:

App.factory('bluetooth', function() {
    var bluetoothSerial = cordova.require('bluetoothSerial');

    return {
        sendMessage: function(message) {
            // interact with bluetoothSerial
        }
    };
});

Then, your controllers can require it:

App.controller('appCtrl', function(bluetooth) {
    $scope.communicate = function() {
        bluetooth.sendMessage("all your base are belong to us");
    };
});

Good luck!

Upvotes: 3

Related Questions