Skip to content

Commit

Permalink
Update AndroidUSBInterface
Browse files Browse the repository at this point in the history
* Update AndroidUSBInterface.java

1. Transform the VID variable into an array.
2. Add the new Vendor ID to support the EXAR brand.
3. Replace the name of variable FTDI_PIDS with UART_PIDS.
4. Add the new PID of the XR21V1410 for newly added Vendor ID.
5. Add a new condition to find devices (FTDI or EXAR).

* Update AndroidUSBInterface.java

Refactor condition for FTDI and EXAR vendors
  • Loading branch information
hhovhann committed May 25, 2022
1 parent 5fa1508 commit 87651e6
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@
public class AndroidUSBInterface implements IConnectionInterface {

// Constants.
private static final int VID = 0x0403;
private static final int[] FTDI_PIDS = {
private static final int[] VID = {
0x0403, // FTDI
0x04E2, // EXAR
};
private static final int[] UART_PIDS = {
0x1410, // XR21V1410
0x6001, // FT232 and FT245
//0x6010, // FT2232
0x6011, // FT4232
Expand Down Expand Up @@ -410,14 +414,18 @@ private UsbDevice findDevice() {
UsbDevice usbDevice = null;
HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
for (UsbDevice device:deviceList.values()) {
if (device.getVendorId() == VID) {
for (int pid:FTDI_PIDS) {
if (device.getVendorId() == VID[0]) {
for (int pid:UART_PIDS) {
if (device.getProductId() == pid) {
usbDevice = device;
logger.info("USB XBee Android device found: " + usbDevice.getDeviceName());
logger.info("USB XBee Android device from FTDI vendor found: " + usbDevice.getDeviceName());
break;
}
}
} else if (device.getVendorId() == VID[1] && device.getProductId() == UART_PIDS[0]){
usbDevice = device;
logger.info("USB XBee Android device from EXAR vendor found: " + usbDevice.getDeviceName());
break;
}
if (usbDevice != null) {
break;
Expand Down

0 comments on commit 87651e6

Please sign in to comment.