-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update AndroidUSBInterface.java #24
Conversation
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).
Refactor condition for FTDI and EXAR vendors
if (device.getVendorId() == VID) { | ||
for (int pid:FTDI_PIDS) { | ||
if (device.getVendorId() == VID[0]) { | ||
for (int pid:UART_PIDS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MINOR: This could be done by checking contains deviceProductId in defined array:
PSEUDO CODE:
if (device.getVendorId() == VID[0] && Arrays.asList(FTDI_PIDS).contains(device.getProductId())){
usbDevice = device;
logger.info("USB XBee Android device from FTDI vendor found: " + usbDevice.getDeviceName());
break;
}
break; | ||
} | ||
} | ||
} else if (device.getVendorId() == VID[1] && device.getProductId() == UART_PIDS[0]){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition will be O(1) instead of the previous logic when I have tried to merge the checks together in the first if. Of course, this could be refactored as well to have more clean code here.
Could be two small functions:
containsDevice
and containsProduct
and those functions will use getDevice logic
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: Add different logs to be sure that the new EXAR vendor device was found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please contact contact@beechat.network to claim bounty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unresponsive email
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share an email here and we'll contact you today? thanks in advance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unresponsive email
Reference Document:
May24th.docx