2

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..

4
  • Can you even access bluetooth from a web browser? I don't think you can unless there's an API for it on your device Commented Dec 5, 2013 at 0:21
  • I meant from mobile app, so my application converted in PhoneGap to..let's call it native. Commented Dec 5, 2013 at 0:22
  • You should probably mention that in your question. Commented Dec 5, 2013 at 0:22
  • This is not an AngularJS question (or iOS or Android, for that matter). It is a Cordova question. I've edited your tags. Hopefully the Cordova community can help you. Commented Dec 5, 2013 at 11:22

1 Answer 1

3

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.