title: Cordova bluetooth plugins
body: <p>I'm developing android app in cordova where i want read data sent from bluetooth.
  I'm testing on Android Lolipop (Sony XPERIA M2) and <a href="https://portal.motorolasolutions.com/Support/US-EN/Mobile+Networks+RFID+and+BarCode+Scanners/Bar+Code+Scanning/General+Purpose+Scanners/CS3000" rel="nofollow">bluetooth barcode scanner</a>.</p>
  
  <p>For this purpose i tried to use plugins for cordova.
  Tested:</p>
  
  <p><a href="https://www.npmjs.com/package/cordova-plugin-bluetoothle" rel="nofollow">https://www.npmjs.com/package/cordova-plugin-bluetoothle</a></p>
  
  <p><a href="https://www.npmjs.com/package/cordova-plugin-networking-bluetooth" rel="nofollow">https://www.npmjs.com/package/cordova-plugin-networking-bluetooth</a></p>
  
  <p><a href="https://github.com/tanelih/phonegap-bluetooth-plugin" rel="nofollow">https://github.com/tanelih/phonegap-bluetooth-plugin</a></p>
  
  <p><a href="https://github.com/don/BluetoothSerial" rel="nofollow">https://github.com/don/BluetoothSerial</a></p>
  
  <p>and many others.</p>
  
  <p>Every time i was possible to find my device but none of these plugins allow me to connect to scanner.</p>
  
  <p>I got error: <strong>READ FAILED, SOCKET MIGHT CLOSED OR TIMEOUT, ERROR CODE: 9</strong></p>
  
  <p>My mobile is connected and paired with scanner correctly but i cant figure out why i cant connect via my app.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>  onDeviceReady: function () {
      var dev = {};
      app.receivedEvent('deviceready');
      window.bluetooth.enable(function () {
          alert("SUCCESS");
      }, function () {
          alert("FAILED");
      });
      window.bluetooth.startDiscovery(onDeviceDiscovered, onDiscoveryFinished, onError);
  
      function onDeviceDiscovered(device) {
          alert("Found device " + device.address);
          if (device.address === "40:83:DE:4B:D4:12") { // address of scanner
              window.bluetooth.getUuids(onUuidsRetrieved, onError, device.address);
          }
      }
      function onDiscoveryFinished() {
          alert("SUCC FINISHED");
          if (dev.address === "40:83:DE:4B:D4:12") {
              alert("Trying to connect...");
              window.bluetooth.connect(onConnected, onErrorConn, {
                  address: dev.address,
                  uuid: dev.uuids[0]
              });
          }
      }
        function onConnected() {
          alert("Connected");
      }
  
      function onUuidsRetrieved(device) {
          alert(device.address + " UUID: " + device.uuids);
          if (device.address === "40:83:DE:4B:D4:12") {
              dev = device;
          }
      }
  
      function onError() {
          alert("ERROR");
      }
  
      function onErrorConn(error) {
          alert(error.code + " " + error.message);
      }
  
  
  }
  </code></pre>
  
  <p>Was someone facing to same issue ?</p>
  
  <p>Thanks for all your help.</p>