Communication between PhoneGap, usb external device and Android host mode
Asked Answered
U

3

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

Unexpected answered 18/9, 2013 at 18:55 Comment(0)
C
7

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

Maybe it will fit your needs

Cele answered 1/5, 2014 at 11:56 Comment(2)
Invoking "serial.requestPermission" returns updates the error: "No device found!". How do I recognize my device?Victorvictoria
Hello, Please provide more detailled information about your issue here: github.com/xseignard/cordovarduino/issuesCele
K
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.

Kingsbury answered 18/9, 2013 at 20:21 Comment(0)
E
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
);
Errantry answered 26/8, 2020 at 12:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.