kopia lustrzana https://github.com/felHR85/UsbSerial
added a method for creating specific UsbSerialDevice objects
rodzic
a47ee7637e
commit
5e79ed88c6
|
@ -16,6 +16,12 @@ import android.hardware.usb.UsbRequest;
|
|||
|
||||
public abstract class UsbSerialDevice implements UsbSerialInterface
|
||||
{
|
||||
public static final String CDC = "cdc";
|
||||
public static final String CH34x = "ch34x";
|
||||
public static final String CP210x = "cp210x";
|
||||
public static final String FTDI = "ftdi";
|
||||
public static final String PL2303 = "pl2303";
|
||||
|
||||
private static final String CLASS_ID = UsbSerialDevice.class.getSimpleName();
|
||||
|
||||
private static boolean mr1Version;
|
||||
|
@ -88,6 +94,22 @@ public abstract class UsbSerialDevice implements UsbSerialInterface
|
|||
return null;
|
||||
}
|
||||
|
||||
public static UsbSerialDevice createUsbSerialDevice(String type, UsbDevice device, UsbDeviceConnection connection, int iface){
|
||||
if(type.equals(FTDI)){
|
||||
return new FTDISerialDevice(device, connection, iface);
|
||||
}else if(type.equals(CP210x)){
|
||||
return new CP2102SerialDevice(device, connection, iface);
|
||||
}else if(type.equals(PL2303)){
|
||||
return new PL2303SerialDevice(device, connection, iface);
|
||||
}else if(type.equals(CH34x)){
|
||||
return new CH34xSerialDevice(device, connection, iface);
|
||||
}else if(type.equals(CDC)){
|
||||
return new CDCSerialDevice(device, connection, iface);
|
||||
}else{
|
||||
throw new IllegalArgumentException("Invalid type argument. Must be:cdc, ch34x, cp210x, ftdi or pl2303");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSupported(UsbDevice device)
|
||||
{
|
||||
int vid = device.getVendorId();
|
||||
|
|
Ładowanie…
Reference in New Issue