10

I need to communicate with an external device with PhoneGap on Android.

It is working by bluetooth with a PhoneGap plugin. Now I want to communicate by the USB port.

Is is possible with PhoneGap, to have access to an external device, by using the USB host capabilities of an Android device?

Any existing PhoneGap / Cordova plugins?

Any examples?

I'm having a hard time finding something similar to prove my concept...

iPeo
  • 399
  • 2
  • 7
  • 16

3 Answers3

7

I have developed such plugin, see https://github.com/xseignard/cordovarduino

Maybe it will fit your needs

xavier.seignard
  • 11,254
  • 13
  • 51
  • 75
  • Invoking "serial.requestPermission" returns updates the error: "No device found!". How do I recognize my device? – Tbseven Feb 03 '15 at 20:02
  • Hello, Please provide more detailled information about your issue here: https://github.com/xseignard/cordovarduino/issues – xavier.seignard Feb 04 '15 at 09:24
0

I think you'll have to write your own Cordova plugin that uses USB Host api: http://developer.android.com/guide/topics/connectivity/usb/host.html I couldn't find any preexisting plugins.

MBillau
  • 5,366
  • 2
  • 28
  • 29
0

Use cordova-plugin-usb-event to list all connected devices's PID & VID

cordova.plugins.usbevent.listDevices(
      function(list) {
        console.log(list);
      },
      function(error) {
        console.log(error);
      });

And write and receive data via cordovarduino

var errorCallback = function(message) {
    alert('Error: ' + message);
};

serial.requestPermission({
    vid: '1d50',
    pid: '607d',
    driver: 'FtdiSerialDriver' // or any other
},
    function(successMessage) {
        serial.open(
            {baudRate: 9600},
            function(successMessage) {
                serial.write(
                    '1',
                    function(successMessage) {
                        alert(successMessage);
                    },
                    errorCallback
                );
            },
            errorCallback
        );
    },
    errorCallback
);
Mamdouh Saeed
  • 2,302
  • 1
  • 9
  • 11