title: PhoneGap Bluetooth Plugin on Android device
body: <p>I've been trying to get a bluetooth plugin for PhoneGap working but I can't seem to figure out where I'm going wrong. Firstly, my test device is a Galaxy S3 (GT-19305T) and the applications were built using the <a href="http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html">PhoneGap CLI</a>.</p>
  
  <p>The plugin I am attempting to use can be found <a href="https://github.com/tanelih/phonegap-bluetooth-plugin">here</a> with an example <a href="http://blogit.jamk.fi/metsaapuilta/2013/10/24/bluetooth-for-phonegap/">here</a>.</p>
  
  <p>I tried the example which didn't seem to actually do anything. </p>
  
  <p>So then I went basic, and tried using the plugins with examples given by PhoneGap. I could quite easily get all of these working. In my example, I am using the basic device information plugin.</p>
  
  <p>Here is some example code:</p>
  
  <p><strong>Javascript:</strong></p>
  
  <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt;
      // Wait for device API libraries to load
      document.addEventListener("deviceready", onDeviceReady, false);
      // device APIs are available
      function onDeviceReady() {
          var element = document.getElementById('deviceProperties');
          element.innerHTML = 'Device Model: '    + device.model    + '&lt;br /&gt;' +
                              'Device Cordova: '  + device.cordova  + '&lt;br /&gt;' +
                              'Device Platform: ' + device.platform + '&lt;br /&gt;' +
                              'Device UUID: '     + device.uuid     + '&lt;br /&gt;' +
                              'Device Version: '  + device.version  + '&lt;br /&gt;';
          var btstatus = document.getElementById('status');
          btstatus.innerHTML = "Getting bluetooth information";
  
          window.bluetooth.isEnabled(isEnabledSuccess, isEnabledError);
      }
  
      function checkBluetoothStatus() {
          var btstatus = document.getElementById('status');
          btstatus.innerHTML = "Checking bluetooth information";
          window.bluetooth.isEnabled(isEnabledSuccess, isEnabledError);
      }
  
      function isEnabledSuccess(isEnabled){
         var btstatus = document.getElementById('status');
         if(isEnabled){
           btstatus.innerHTML = "Enabled";
         }else{
           btstatus.innerHTML = "Disabled";
         }
      }
  
      function isEnabledError(error){
         var btstatus = document.getElementById('status');
         btstatus.innerHTML = "Cannot determine Bluetooth status: " + error.message;
      }
  
      function enableBluetooth(){
          var btstatus = document.getElementById('status');
          btstatus.innerHTML = "Attempting to turn bluetooth on";
          window.bluetooth.enable(bluetoothTestSucces, bluetoothTestFail);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Html:</strong></p>
  
  <pre><code>  &lt;body&gt;
      &lt;p id="deviceProperties"&gt;Loading device properties...&lt;/p&gt;
      &lt;br /&gt;
      &lt;button onclick="enableBluetooth();"&gt;Enable Bluetooth&lt;/button&gt;
      &lt;br /&gt;
      &lt;button onclick="checkBluetoothStatus();"&gt;Check Bluetooth Status&lt;/button&gt;
      &lt;br /&gt;
      &lt;p id="status"&gt;Loading bluetooth information...&lt;/p&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p>So basically I am trying to either get the plugin to return the current bluetooth connectivity information, or enable the bluetooth upon clicking the "enable bluetooth" button.</p>
  
  <p>Unfortunately nothing has worked so far and as I stated earlier I am not sure where I am going wrong.</p>
  
  <p>I have tried applying it manually and by using the CLI. </p>